Skip to content

Commit

Permalink
Merge pull request #5206 from DFE-Digital/CST-2766-sit-pre-term-comms
Browse files Browse the repository at this point in the history
[CST-2766] Add nomination_link param to sit pre term comms mailer
  • Loading branch information
leoapost authored Oct 2, 2024
2 parents 29beff8 + 845a73a commit 7624651
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/mailers/school_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ def finance_errors_with_nqt_plus_one_and_ecf_year_2_local_authority_version

def sit_pre_term_reminder_to_report_any_changes
induction_coordinator = params[:induction_coordinator]
nomination_url = params[:nomination_url]
sit_name = induction_coordinator.user.full_name
email_address = induction_coordinator.user.email

Expand All @@ -564,6 +565,7 @@ def sit_pre_term_reminder_to_report_any_changes
personalisation: {
name: sit_name,
email_address:,
nomination_link: nomination_url,
},
).tag(:sit_pre_term_reminder_to_report_any_changes).associate_with(induction_coordinator, as: :induction_coordinator_profile)
end
Expand Down
3 changes: 2 additions & 1 deletion app/services/bulk_mailers/school_reminder_comms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,9 @@ def contact_sits_pre_term_to_report_any_changes
.find_each do |school|
school.induction_coordinator_profiles.each do |induction_coordinator|
email_count += 1
nomination_url = nomination_url(email: induction_coordinator.user.email, school:)

SchoolMailer.with(induction_coordinator:).sit_pre_term_reminder_to_report_any_changes.deliver_later(wait: get_waiting_time(email_count))
SchoolMailer.with(induction_coordinator:, nomination_url:).sit_pre_term_reminder_to_report_any_changes.deliver_later(wait: get_waiting_time(email_count))
end
end

Expand Down
2 changes: 2 additions & 0 deletions spec/mailers/school_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,12 @@
describe "#sit_pre_term_reminder_to_report_any_changes" do
let(:induction_coordinator) { create(:seed_induction_coordinator_profile, :with_user) }
let(:email_address) { induction_coordinator.user.email }
let(:nomination_link) { "https://ecf-dev.london.cloudapps/nominations/start?token=123" }

let(:sit_pre_term_reminder_to_report_any_changes) do
SchoolMailer.with(
induction_coordinator:,
nomination_link:,
).sit_pre_term_reminder_to_report_any_changes.deliver_now
end

Expand Down
8 changes: 7 additions & 1 deletion spec/services/bulk_mailers/school_reminder_comms_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,17 @@

describe "#contact_sits_pre_term_to_report_any_changes" do
context "when a school rans FIP or CIP and has not opted out of updates" do
let(:nomination_url) { "http://nomination.example.com" }

before do
allow(service).to receive(:nomination_url).with(email: sit_profile.user.email, school:).and_return(nomination_url)
end

it "mails the induction coordinator" do
expect {
service.contact_sits_pre_term_to_report_any_changes
}.to have_enqueued_mail(SchoolMailer, :sit_pre_term_reminder_to_report_any_changes)
.with(params: { induction_coordinator: sit_profile }, args: [])
.with(params: { induction_coordinator: sit_profile, nomination_url: }, args: [])
end
end

Expand Down

0 comments on commit 7624651

Please sign in to comment.