Skip to content

Commit

Permalink
claimant does not receive rejection if no email
Browse files Browse the repository at this point in the history
  • Loading branch information
asmega committed Nov 1, 2024
1 parent 381912a commit db03bfe
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 18 deletions.
5 changes: 4 additions & 1 deletion app/controllers/admin/decisions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ def send_claim_result_email
return if @claim.awaiting_qa?

ClaimMailer.approved(@claim).deliver_later if @claim.latest_decision.result == "approved"
ClaimMailer.rejected(@claim).deliver_later if @claim.latest_decision.result == "rejected"

if @claim.latest_decision.result == "rejected" && @claim.email_address.present?
ClaimMailer.rejected(@claim).deliver_later
end

if @claim.latest_decision.result == "rejected" && @claim.has_early_years_policy?
ClaimMailer.rejected_provider_notification(@claim).deliver_later
Expand Down
60 changes: 43 additions & 17 deletions spec/features/admin/admin_reject_claim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,25 +110,51 @@
end

context "early years claim" do
let!(:claim) do
create(
:claim,
:submitted,
policy: Policies::EarlyYearsPayments
)
context "claimant has not completed their half" do
let!(:claim) do
create(
:claim,
:submitted,
policy: Policies::EarlyYearsPayments,
email_address: nil
)
end

scenario "rejecting sends email to provider only when claimant yet to complete" do
visit admin_claim_tasks_path(claim)
click_on "Approve or reject this claim"
choose "Reject"
check "Claim cancelled by employer"

expect {
click_button "Confirm decision"
}.to change { enqueued_jobs.count { |job| job[:job] == ActionMailer::MailDeliveryJob } }.by(1)

expect(page).to have_content("Claim has been rejected successfully")
end
end

scenario "rejecting sends email to claimant + provider" do
visit admin_claim_tasks_path(claim)
click_on "Approve or reject this claim"
choose "Reject"
check "Claim cancelled by employer"

expect {
click_button "Confirm decision"
}.to change { enqueued_jobs.count { |job| job[:job] == ActionMailer::MailDeliveryJob } }.by(2)

expect(page).to have_content("Claim has been rejected successfully")
context "claimant has completed their half" do
let!(:claim) do
create(
:claim,
:submitted,
policy: Policies::EarlyYearsPayments
)
end

scenario "rejecting sends email to claimant + provider" do
visit admin_claim_tasks_path(claim)
click_on "Approve or reject this claim"
choose "Reject"
check "Claim cancelled by employer"

expect {
click_button "Confirm decision"
}.to change { enqueued_jobs.count { |job| job[:job] == ActionMailer::MailDeliveryJob } }.by(2)

expect(page).to have_content("Claim has been rejected successfully")
end
end
end
end

0 comments on commit db03bfe

Please sign in to comment.