-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/vocab-query-user-parameter
- Loading branch information
Showing
6 changed files
with
240 additions
and
119 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 |
---|---|---|
|
@@ -58,8 +58,9 @@ describe('The EmailService', function () { | |
const format = "html"; | ||
const cc = '[email protected]'; | ||
const bcc = '[email protected]'; | ||
const replyTo = '[email protected]'; | ||
|
||
const sendResponse = EmailService.sendMessage(to, body, subject, from, format, cc, bcc); | ||
const sendResponse = EmailService.sendMessage(to, body, subject, from, format, cc, bcc, {replyTo: replyTo}); | ||
|
||
sendResponse.subscribe(sendResult => { | ||
expect(sendResult['success']).to.eql(true); | ||
|
@@ -192,4 +193,59 @@ describe('The EmailService', function () { | |
}); | ||
}); | ||
|
||
describe('send record notification', function () { | ||
let originalEmailDisabledValue; | ||
beforeEach(function (done) { | ||
originalEmailDisabledValue = _.get(sails.config , 'services.email.disabled'); | ||
done(); | ||
}); | ||
afterEach(function (done) { | ||
_.set(sails.config , 'services.email.disabled', originalEmailDisabledValue); | ||
done(); | ||
}); | ||
it('should respect disabled setting', async function () { | ||
_.set(sails.config, 'services.email.disabled', "true"); | ||
const oid = "test-oid"; | ||
const record = ""; | ||
const options = {triggerCondition: ""}; | ||
const user = ""; | ||
const response = ""; | ||
const result = await EmailService.sendRecordNotification(oid, record, options, user, response).toPromise(); | ||
expect(result).to.equal(null); | ||
}); | ||
|
||
it('should fail when to address is not valid', async function () { | ||
const oid = "test-oid"; | ||
const record = {testing: true}; | ||
const options = {triggerCondition: "<%= record.testing %>"}; | ||
const user = ""; | ||
const response = {}; | ||
const result = await EmailService.sendRecordNotification(oid, record, options, user, response).toPromise(); | ||
expect(result).to.equal(null); | ||
}); | ||
|
||
it('should send email when trigger condition matches', async function () { | ||
const oid = "test-oid"; | ||
const record = { | ||
metadata: { | ||
testing: true, | ||
title: "Testing title", | ||
email_address: "[email protected]", | ||
} | ||
}; | ||
const options = { | ||
triggerCondition: "<%= record.metadata.testing == true %>", | ||
to: "<%= record.metadata.email_address %>", | ||
subject: "Testing email sending", | ||
template: "publicationReview", | ||
otherSendOptions: { | ||
'replyTo': '[email protected]', | ||
} | ||
}; | ||
const user = ""; | ||
const response = {content: "response content"}; | ||
const result = await EmailService.sendRecordNotification(oid, record, options, user, response).toPromise(); | ||
expect(result).to.equal(response); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.