-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #172 from agorapulse/feature/allow-adding-tags-on-…
…emails Allow adding tags on emails
- Loading branch information
Showing
12 changed files
with
118 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,18 +43,20 @@ class SendEmailSpec extends Specification { | |
file.createNewFile() | ||
file.text = 'not a real PDF' | ||
String thePath = file.canonicalPath | ||
Map<String, String> mapOfTags = [myTagKey: 'myTagValue'] | ||
when: | ||
// tag::builder[] | ||
EmailDeliveryStatus status = service.send { // <1> | ||
subject 'Hi Paul' // <2> | ||
from '[email protected]' // <3> | ||
to '[email protected]' // <4> | ||
htmlBody '<p>This is an example body</p>' // <5> | ||
attachment { // <6> | ||
filepath thePath // <7> | ||
filename 'test.pdf' // <8> | ||
mimeType 'application/pdf' // <9> | ||
description 'An example pdf' // <10> | ||
tags mapOfTags // <6> | ||
attachment { // <7> | ||
filepath thePath // <8> | ||
filename 'test.pdf' // <9> | ||
mimeType 'application/pdf' // <10> | ||
description 'An example pdf' // <11> | ||
} | ||
} | ||
// end::builder[] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,8 @@ | |
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
@@ -54,18 +56,21 @@ public void testSendEmail() throws IOException { | |
|
||
Files.write(file.toPath(), Collections.singletonList("not a real PDF")); | ||
String filepath = file.getCanonicalPath(); | ||
Map<String, String> mapOfTags = new HashMap<>(); | ||
mapOfTags.put("myTagKey", "myTagValue"); | ||
|
||
// tag::builder[] | ||
EmailDeliveryStatus status = service.send(e -> // <1> | ||
e.subject("Hi Paul") // <2> | ||
.from("[email protected]") // <3> | ||
.to("[email protected]") // <4> | ||
.htmlBody("<p>This is an example body</p>") // <5> | ||
.attachment(a -> // <6> | ||
a.filepath(filepath) // <7> | ||
.filename("test.pdf") // <8> | ||
.mimeType("application/pdf") // <9> | ||
.description("An example pdf") // <10> | ||
.tags(mapOfTags) // <6> | ||
.attachment(a -> // <7> | ||
a.filepath(filepath) // <8> | ||
.filename("test.pdf") // <9> | ||
.mimeType("application/pdf") // <10> | ||
.description("An example pdf") // <11> | ||
) | ||
); | ||
// end::builder[] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,12 +44,15 @@ class SimpleEmailServiceSpec extends Specification { | |
) | ||
|
||
void "test transactionalEmailWithClosure"() { | ||
given: | ||
Map<String, String> customTags = [key1: 'value1', key2: 'value2'] | ||
when: | ||
TransactionalEmail transactionalEmail = SimpleEmailService.email { | ||
subject 'Hi Paul' | ||
from '[email protected]' | ||
to '[email protected]' | ||
htmlBody '<p>This is an example body</p>' | ||
tags customTags | ||
attachment { | ||
filename 'test.pdf' | ||
filepath '/tmp/test.pdf' | ||
|
@@ -64,6 +67,7 @@ class SimpleEmailServiceSpec extends Specification { | |
transactionalEmail.htmlBody == '<p>This is an example body</p>' | ||
transactionalEmail.from == '[email protected]' | ||
transactionalEmail.recipients == ['[email protected]'] | ||
transactionalEmail.tags == [key1: 'value1', key2: 'value2'] | ||
transactionalEmail.attachments.size() == 1 | ||
transactionalEmail.attachments.first().filename == 'test.pdf' | ||
transactionalEmail.attachments.first().filepath == '/tmp/test.pdf' | ||
|
@@ -82,6 +86,7 @@ class SimpleEmailServiceSpec extends Specification { | |
htmlBody '<p>This is an example body</p>' | ||
to '[email protected]' | ||
from '[email protected]' | ||
tags customTags | ||
attachment { | ||
filepath f.absolutePath | ||
} | ||
|
@@ -93,6 +98,7 @@ class SimpleEmailServiceSpec extends Specification { | |
transactionalEmail.htmlBody == '<p>This is an example body</p>' | ||
transactionalEmail.from == '[email protected]' | ||
transactionalEmail.recipients == ['[email protected]'] | ||
transactionalEmail.tags == [key1: 'value1', key2: 'value2'] | ||
transactionalEmail.attachments.size() == 1 | ||
transactionalEmail.attachments.first().filename == 'groovylogo.png' | ||
transactionalEmail.attachments.first().filepath == f.absolutePath | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,18 +46,20 @@ class SendEmailSpec extends Specification { | |
file.createNewFile() | ||
file.text = 'not a real PDF' | ||
String thePath = file.canonicalPath | ||
Map<String, String> mapOfTags = [myTagKey: 'myTagValue'] | ||
when: | ||
// tag::builder[] | ||
EmailDeliveryStatus status = service.send { // <1> | ||
subject 'Hi Paul' // <2> | ||
from '[email protected]' // <3> | ||
to '[email protected]' // <4> | ||
htmlBody '<p>This is an example body</p>' // <5> | ||
attachment { // <6> | ||
filepath thePath // <7> | ||
filename 'test.pdf' // <8> | ||
mimeType 'application/pdf' // <9> | ||
description 'An example pdf' // <10> | ||
tags mapOfTags // <6> | ||
attachment { // <7> | ||
filepath thePath // <8> | ||
filename 'test.pdf' // <9> | ||
mimeType 'application/pdf' // <10> | ||
description 'An example pdf' // <11> | ||
} | ||
} | ||
// end::builder[] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,8 @@ | |
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
@@ -55,18 +57,21 @@ public void testSendEmail() throws IOException { | |
file.createNewFile(); | ||
Files.write(file.toPath(), Collections.singletonList("not a real PDF")); | ||
String filepath = file.getCanonicalPath(); | ||
Map<String, String> mapOfTags = new HashMap<>(); | ||
mapOfTags.put("myTagKey", "myTagValue"); | ||
|
||
// tag::builder[] | ||
EmailDeliveryStatus status = service.send(e -> // <1> | ||
e.subject("Hi Paul") // <2> | ||
.from("[email protected]") // <3> | ||
.to("[email protected]") // <4> | ||
.htmlBody("<p>This is an example body</p>") // <5> | ||
.attachment(a -> // <6> | ||
a.filepath(filepath) // <7> | ||
.filename("test.pdf") // <8> | ||
.mimeType("application/pdf") // <9> | ||
.description("An example pdf") // <10> | ||
.tags(mapOfTags) // <6> | ||
.attachment(a -> // <7> | ||
a.filepath(filepath) // <8> | ||
.filename("test.pdf") // <9> | ||
.mimeType("application/pdf") // <10> | ||
.description("An example pdf") // <11> | ||
) | ||
); | ||
// end::builder[] | ||
|
Oops, something went wrong.