4 changed files with 65 additions and 1 deletions
@ -0,0 +1,17 @@ |
|||||||
|
class MergeCompletionMailer < NotifyMailer |
||||||
|
MERGE_COMPLETION_TEMPLATE_ID = "xxx".freeze |
||||||
|
|
||||||
|
def send_merge_completion_mail(email, merged_organisation_name, absorbing_organisation_name, merge_date, username) |
||||||
|
send_email( |
||||||
|
email, |
||||||
|
MERGE_COMPLETION_TEMPLATE_ID, |
||||||
|
{ |
||||||
|
merged_organisation_name:, |
||||||
|
absorbing_organisation_name:, |
||||||
|
merge_date:, |
||||||
|
email:, |
||||||
|
username:, |
||||||
|
}, |
||||||
|
) |
||||||
|
end |
||||||
|
end |
||||||
@ -0,0 +1,26 @@ |
|||||||
|
require "rails_helper" |
||||||
|
|
||||||
|
RSpec.describe MergeCompletionMailer do |
||||||
|
let(:notify_client) { instance_double(Notifications::Client) } |
||||||
|
|
||||||
|
before do |
||||||
|
allow(Notifications::Client).to receive(:new).and_return(notify_client) |
||||||
|
allow(notify_client).to receive(:send_email).and_return(true) |
||||||
|
end |
||||||
|
|
||||||
|
describe "#send_merge_completion_mail" do |
||||||
|
let(:merge_date) { Time.zone.today } |
||||||
|
|
||||||
|
it "sends a merge completion E-mail via notify" do |
||||||
|
expect(notify_client).to receive(:send_email).with(hash_including({ personalisation: hash_including({ |
||||||
|
merged_organisation_name: "merged organisation", |
||||||
|
absorbing_organisation_name: "absorbing organisation", |
||||||
|
merge_date:, |
||||||
|
email: "user@example.com", |
||||||
|
username: "user", |
||||||
|
}) })) |
||||||
|
|
||||||
|
described_class.new.send_merge_completion_mail("user@example.com", "merged organisation", "absorbing organisation", merge_date, "user") |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
Loading…
Reference in new issue