From 39b388e7bab0d50e8321b585ca80f40757a4e9f8 Mon Sep 17 00:00:00 2001 From: Ben Abraham <16797406+Kizr@users.noreply.github.com> Date: Mon, 16 Dec 2024 12:30:43 +0000 Subject: [PATCH] Add the claim_requires_clawback mail to the user mailer --- app/mailers/claims/user_mailer.rb | 13 ++++++++ config/locales/en/claims/user_mailer.yml | 19 +++++++++++ spec/mailers/claims/user_mailer_spec.rb | 32 +++++++++++++++++++ .../previews/claims/user_mailer_preview.rb | 4 +++ 4 files changed, 68 insertions(+) diff --git a/app/mailers/claims/user_mailer.rb b/app/mailers/claims/user_mailer.rb index d557314e4..5ff69c27e 100644 --- a/app/mailers/claims/user_mailer.rb +++ b/app/mailers/claims/user_mailer.rb @@ -56,4 +56,17 @@ def claim_created_support_notification(claim, user) link_to_claim:, ) end + + def claim_requires_clawback(claim, user) + link_to_claim = claims_school_claim_url(id: claim.id, school_id: claim.school.id) + + notify_email to: user.email, + subject: t(".subject"), + body: t(".body", + user_name: user.first_name, + reference: claim.reference, + link_to_claim:, + support_email:, + service_name:) + end end diff --git a/config/locales/en/claims/user_mailer.yml b/config/locales/en/claims/user_mailer.yml index ba28f207b..b38c4a415 100644 --- a/config/locales/en/claims/user_mailer.yml +++ b/config/locales/en/claims/user_mailer.yml @@ -81,3 +81,22 @@ en: Regards Claim funding for mentor training team + + claim_requires_clawback: + subject: ITT mentor claim requires a clawback + body: | + Dear %{user_name}, + + We have amended your claim to reflect the amount being clawed back by the Education and Skills Funding Agency (ESFA). They will contact you to discuss how they will claim this money from you. + + The affected claim reference is: %{reference} + + You can view the updated claim on Claim funding for mentor training: + + %{link_to_claim} + + # Give feedback or report a problem + If you have any questions or feedback, please contact the team at [%{support_email}](mailto:%{support_email}). + + Regards + %{service_name} team diff --git a/spec/mailers/claims/user_mailer_spec.rb b/spec/mailers/claims/user_mailer_spec.rb index 796335405..7b7102bba 100644 --- a/spec/mailers/claims/user_mailer_spec.rb +++ b/spec/mailers/claims/user_mailer_spec.rb @@ -213,4 +213,36 @@ end end end + + describe "#claim_requires_clawback" do + subject(:clawback_email) { described_class.claim_requires_clawback(claim, user) } + + let(:user) { create(:claims_user) } + let(:school) { create(:claims_school, region: regions(:inner_london)) } + let(:claim) { create(:claim, reference: "123", school:) } + + it "sends the clawback email" do + create(:mentor_training, claim:, hours_completed: 10) + + expect(clawback_email.to).to contain_exactly(user.email) + expect(clawback_email.subject).to eq("ITT mentor claim requires a clawback") + expect(clawback_email.body.to_s.strip).to eq(<<~EMAIL.strip) + Dear #{user.first_name}, + + We have amended your claim to reflect the amount being clawed back by the Education and Skills Funding Agency (ESFA). They will contact you to discuss how they will claim this money from you. + + The affected claim reference is: #{claim.reference} + + You can view the updated claim on Claim funding for mentor training: + + http://claims.localhost/schools/#{school.id}/claims/#{claim.id} + + # Give feedback or report a problem + If you have any questions or feedback, please contact the team at [ittmentor.funding@education.gov.uk](mailto:ittmentor.funding@education.gov.uk). + + Regards + Claim funding for mentor training team + EMAIL + end + end end diff --git a/spec/mailers/previews/claims/user_mailer_preview.rb b/spec/mailers/previews/claims/user_mailer_preview.rb index 06ddb3041..b916134f4 100644 --- a/spec/mailers/previews/claims/user_mailer_preview.rb +++ b/spec/mailers/previews/claims/user_mailer_preview.rb @@ -14,4 +14,8 @@ def claim_submitted_notification def claim_created_support_notification Claims::UserMailer.claim_created_support_notification(Claims::Claim.draft.first, Claims::User.first) end + + def claim_requires_clawback + Claims::UserMailer.claim_requires_clawback(Claims::Claim.first, Claims::User.first) + end end