diff --git a/app/mailers/claims/esfa_mailer.rb b/app/mailers/claims/esfa_mailer.rb index 0a31243b6..c52e43808 100644 --- a/app/mailers/claims/esfa_mailer.rb +++ b/app/mailers/claims/esfa_mailer.rb @@ -1,10 +1,13 @@ class Claims::ESFAMailer < Claims::ApplicationMailer - ESFA_EMAIL_ADDRESS = "esfa@example.com".freeze - private_constant :ESFA_EMAIL_ADDRESS - def claims_require_clawback(url_for_csv) - notify_email to: ESFA_EMAIL_ADDRESS, + notify_email to: esfa_email_addresses, subject: t(".subject"), body: t(".body", url_for_csv:, support_email:, service_name:) end + + private + + def esfa_email_addresses + ENV["CLAIMS_ESFA_EMAIL_ADDRESSES"].split(",") + end end diff --git a/spec/mailers/claims/esfa_mailer_spec.rb b/spec/mailers/claims/esfa_mailer_spec.rb index 6dc676385..f1e15fe48 100644 --- a/spec/mailers/claims/esfa_mailer_spec.rb +++ b/spec/mailers/claims/esfa_mailer_spec.rb @@ -5,12 +5,16 @@ subject(:claims_require_clawback_email) { described_class.claims_require_clawback(url_for_csv) } let(:url_for_csv) { "https://example.com" } - let(:esfa_email) { "esfa@example.com" } + let(:esfa_emails) { %w[example1@education.gov.uk example2@education.gov.uk] } let(:service_name) { "Claim funding for mentor training" } let(:support_email) { "ittmentor.funding@education.gov.uk" } + before do + stub_const("ENV", { "CLAIMS_ESFA_EMAIL_ADDRESSES" => esfa_emails }) + end + it "sends the claims require clawback email" do - expect(claims_require_clawback_email.to).to contain_exactly(esfa_email) + expect(claims_require_clawback_email.to).to match_array(esfa_emails) expect(claims_require_clawback_email.subject).to eq("Claims requiring clawback - Claim funding for mentor training") expect(claims_require_clawback_email.body.to_s.squish).to eq(<<~EMAIL.squish) To ESFA,