From 8a6f49b99df1e6bde90a28b4061da9de5b71919a Mon Sep 17 00:00:00 2001 From: Leonidas Apostolidis Date: Wed, 2 Oct 2024 14:38:54 +0100 Subject: [PATCH 1/2] Add nomination_link placeholder to contact_sits_pre_term_to_report_any_changes mailer --- app/mailers/school_mailer.rb | 2 ++ app/services/bulk_mailers/school_reminder_comms.rb | 3 ++- spec/mailers/school_mailer_spec.rb | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/mailers/school_mailer.rb b/app/mailers/school_mailer.rb index 99a541ff12..86bfa98e4c 100644 --- a/app/mailers/school_mailer.rb +++ b/app/mailers/school_mailer.rb @@ -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 @@ -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 diff --git a/app/services/bulk_mailers/school_reminder_comms.rb b/app/services/bulk_mailers/school_reminder_comms.rb index 8da9331401..eb7938f1fc 100644 --- a/app/services/bulk_mailers/school_reminder_comms.rb +++ b/app/services/bulk_mailers/school_reminder_comms.rb @@ -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 diff --git a/spec/mailers/school_mailer_spec.rb b/spec/mailers/school_mailer_spec.rb index 09f77c8fa0..0e5aeafecc 100644 --- a/spec/mailers/school_mailer_spec.rb +++ b/spec/mailers/school_mailer_spec.rb @@ -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 From 845a73a6c4e76f675c03b16549ff46bab6050035 Mon Sep 17 00:00:00 2001 From: Leonidas Apostolidis Date: Wed, 2 Oct 2024 15:42:23 +0100 Subject: [PATCH 2/2] Update the SchoolReminderComms spec --- spec/services/bulk_mailers/school_reminder_comms_spec.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spec/services/bulk_mailers/school_reminder_comms_spec.rb b/spec/services/bulk_mailers/school_reminder_comms_spec.rb index 4fbfbd643f..f708d39709 100644 --- a/spec/services/bulk_mailers/school_reminder_comms_spec.rb +++ b/spec/services/bulk_mailers/school_reminder_comms_spec.rb @@ -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