Skip to content

Commit

Permalink
Add the claim_requires_clawback mail to the user mailer
Browse files Browse the repository at this point in the history
  • Loading branch information
Kizr committed Dec 17, 2024
1 parent 627335d commit 39b388e
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/mailers/claims/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 19 additions & 0 deletions config/locales/en/claims/user_mailer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
32 changes: 32 additions & 0 deletions spec/mailers/claims/user_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions spec/mailers/previews/claims/user_mailer_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 39b388e

Please sign in to comment.