Skip to content

Commit

Permalink
Remove constant email addresses in favour of env variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kizr committed Dec 17, 2024
1 parent 39b388e commit 57d0df1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
11 changes: 7 additions & 4 deletions app/mailers/claims/esfa_mailer.rb
Original file line number Diff line number Diff line change
@@ -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
8 changes: 6 additions & 2 deletions spec/mailers/claims/esfa_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 57d0df1

Please sign in to comment.