-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 #168 from bobbyrullo/invite_emails
Invite emails
- Loading branch information
Showing
12 changed files
with
99 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,9 +9,11 @@ import ( | |
const ( | ||
textTemplateString = `{{define "T1.txt"}}{{.gift}} from {{.from}} to {{.to}}.{{end}} | ||
{{define "T3.txt"}}Hello there, {{.name}}!{{end}} | ||
{{define "T4.txt"}}Hello there, {{.name}}! Welcome to {{.planet}}!{{end}} | ||
` | ||
htmlTemplateString = `{{define "T1.html"}}<html><body>{{.gift}} from {{.from}} to {{.to}}.</body></html>{{end}} | ||
{{define "T2.html"}}<html><body>Hello, {{.name}}!</body></html>{{end}} | ||
{{define "T4.html"}}<html><body>Hello there, {{.name}}! Welcome to {{.planet}}!</body></html>{{end}} | ||
` | ||
) | ||
|
||
|
@@ -51,6 +53,7 @@ func TestTemplatizedEmailSendMail(t *testing.T) { | |
wantText string | ||
wantHtml string | ||
wantErr bool | ||
ctx map[string]interface{} | ||
}{ | ||
{ | ||
tplName: "T1", | ||
|
@@ -97,11 +100,29 @@ func TestTemplatizedEmailSendMail(t *testing.T) { | |
wantText: "", | ||
wantHtml: htmlStart + "Hello, Alice<script>alert('hacked!')</script>!" + htmlEnd, | ||
}, | ||
{ | ||
tplName: "T4", | ||
from: "[email protected]", | ||
to: "[email protected]", | ||
subject: "hello there", | ||
data: map[string]interface{}{ | ||
"name": "Alice", | ||
}, | ||
wantText: "Hello there, Alice! Welcome to Mars!", | ||
ctx: map[string]interface{}{ | ||
"planet": "Mars", | ||
}, | ||
wantHtml: "<html><body>Hello there, Alice! Welcome to Mars!</body></html>", | ||
}, | ||
} | ||
|
||
for i, tt := range tests { | ||
emailer := &testEmailer{} | ||
templatizer := NewTemplatizedEmailerFromTemplates(textTemplates, htmlTemplates, emailer) | ||
if tt.ctx != nil { | ||
templatizer.SetGlobalContext(tt.ctx) | ||
} | ||
|
||
err := templatizer.SendMail(tt.from, tt.subject, tt.tplName, tt.data, tt.to) | ||
if tt.wantErr { | ||
if err == nil { | ||
|
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 |
---|---|---|
|
@@ -102,7 +102,7 @@ func TestSendResetPasswordEmailHandler(t *testing.T) { | |
wantEmailer: &testEmailer{ | ||
to: str("[email protected]"), | ||
from: "[email protected]", | ||
subject: "Reset your password.", | ||
subject: "Reset Your Password", | ||
}, | ||
wantPRUserID: "ID-1", | ||
wantPRRedirect: &testRedirectURL, | ||
|
@@ -138,7 +138,7 @@ func TestSendResetPasswordEmailHandler(t *testing.T) { | |
wantEmailer: &testEmailer{ | ||
to: str("[email protected]"), | ||
from: "[email protected]", | ||
subject: "Reset your password.", | ||
subject: "Reset Your Password", | ||
}, | ||
wantPRPassword: "password", | ||
wantPRUserID: "ID-1", | ||
|
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<html> | ||
<body> | ||
Welcome to Dex! Click below to set your password: | ||
|
||
<a href="{{ .link }}">Set Password</a> | ||
</body> | ||
</html> |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Welcome to Dex! Click below to set your password: | ||
|
||
Link: | ||
{{ .link }} |
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