Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(JOB-156): Send mail to business contact on interest #205

Merged
merged 1 commit into from
Jan 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion server/src/domain/services/mail-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ const jobsAddedEmailTemplate = require('../../infrastructure/mailing/jobs-added-
function sendInterestEmail(form) {
const subject = `[JobBoard] ${form.interestedConsultant.name} intéressé·e par ${form.missionName} - ${form.activityName}`;
const template = interestEmailTemplate.compile(form);
const mailTo = [config.MAIL_TO];
if (form.businessContactNickname !== 'N/A') {
const businessContactEmail = `${form.businessContactNickname}@octo.com`;
mailTo.push(businessContactEmail);
}

const options = {
from: config.MAIL_FROM,
fromName: 'Le Job Board - Ne pas répondre',
to: config.MAIL_TO,
to: mailTo,
subject,
template,
};
Expand Down
33 changes: 31 additions & 2 deletions server/test/unit/domain/services/mail-service.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('Unit | Service | MailService', () => {
name: 'Samurai Jack',
email: '[email protected]',
},
businessContactNickname: 'XYZ',
businessContactNickname: 'BusinessContactNickname',
missionDirectorNickname: 'ZYX',
octopodLink: 'https://octopod.octo.com/projects/2146904867',
activityName: 'Développeur Front',
Expand All @@ -40,7 +40,36 @@ describe('Unit | Service | MailService', () => {
return promise.then(() => {
expect(mailJet.sendEmail).to.have.been.calledWithExactly({
from: '[email protected]',
to: '[email protected]',
to: ['[email protected]', '[email protected]'],
fromName: 'Le Job Board - Ne pas répondre',
subject: '[JobBoard] Samurai Jack intéressé·e par Oodrive - Liste d\'initié - Développeur Front',
template: 'Interest mail template',
});
});
});

it('should not send an email to business contact if unknown', () => {
// given
const form = {
interestedConsultant: {
name: 'Samurai Jack',
email: '[email protected]',
},
businessContactNickname: 'N/A',
missionDirectorNickname: 'ZYX',
octopodLink: 'https://octopod.octo.com/projects/2146904867',
activityName: 'Développeur Front',
missionName: 'Oodrive - Liste d\'initié',
};

// when
const promise = mailService.sendInterestEmail(form);

// then
return promise.then(() => {
expect(mailJet.sendEmail).to.have.been.calledWithExactly({
from: '[email protected]',
to: ['[email protected]'],
fromName: 'Le Job Board - Ne pas répondre',
subject: '[JobBoard] Samurai Jack intéressé·e par Oodrive - Liste d\'initié - Développeur Front',
template: 'Interest mail template',
Expand Down