From 759e2b7c750cf07197a5a21b5df4eece3c53a05d Mon Sep 17 00:00:00 2001 From: Richard Lynch Date: Tue, 5 Nov 2024 16:59:53 +0000 Subject: [PATCH] Keep task if claim updated with gender When completing the payroll gender task we update the gender on the claim, this removed the payroll gender task causing `Admin::TaskPagination#current_task_index` to be `nil` ultimatly throwing an error when we try to redirect to the `Admin::TaskPagination#next_task_path` (which was nil). --- .../claim_checking_tasks.rb | 2 +- .../claim_checking_tasks.rb | 2 +- ..._claim_with_missing_payroll_gender_spec.rb | 36 +++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/app/models/policies/further_education_payments/claim_checking_tasks.rb b/app/models/policies/further_education_payments/claim_checking_tasks.rb index f6159a4ff5..67471388b5 100644 --- a/app/models/policies/further_education_payments/claim_checking_tasks.rb +++ b/app/models/policies/further_education_payments/claim_checking_tasks.rb @@ -20,7 +20,7 @@ def applicable_task_names tasks << "student_loan_plan" if claim.submitted_without_slc_data? tasks << "payroll_details" if claim.must_manually_validate_bank_details? tasks << "matching_details" if matching_claims.exists? - tasks << "payroll_gender" if claim.payroll_gender_missing? + tasks << "payroll_gender" if claim.payroll_gender_missing? || claim.tasks.exists?(name: "payroll_gender") tasks end diff --git a/app/models/policies/international_relocation_payments/claim_checking_tasks.rb b/app/models/policies/international_relocation_payments/claim_checking_tasks.rb index 61314cfd94..513c0b247e 100644 --- a/app/models/policies/international_relocation_payments/claim_checking_tasks.rb +++ b/app/models/policies/international_relocation_payments/claim_checking_tasks.rb @@ -26,7 +26,7 @@ def applicable_task_names tasks << "teaching_hours" tasks << "payroll_details" if claim.must_manually_validate_bank_details? tasks << "matching_details" if matching_claims.exists? - tasks << "payroll_gender" if claim.payroll_gender_missing? + tasks << "payroll_gender" if claim.payroll_gender_missing? || claim.tasks.exists?(name: "payroll_gender") tasks end diff --git a/spec/features/admin/admin_claim_with_missing_payroll_gender_spec.rb b/spec/features/admin/admin_claim_with_missing_payroll_gender_spec.rb index d5c4c06c50..f3bee0b061 100644 --- a/spec/features/admin/admin_claim_with_missing_payroll_gender_spec.rb +++ b/spec/features/admin/admin_claim_with_missing_payroll_gender_spec.rb @@ -45,4 +45,40 @@ expect(claim.latest_decision).to be_approved expect(claim.latest_decision.created_by).to eq(@signed_in_user) end + + scenario "with a policy where payroll gender is the last task" do + irp_claim = create( + :claim, + :submitted, + policy: Policies::InternationalRelocationPayments, + payroll_gender: :dont_know + ) + + fe_claim = create( + :claim, + :submitted, + policy: Policies::FurtherEducationPayments, + payroll_gender: :dont_know + ) + + visit admin_claim_tasks_path(irp_claim) + + click_on "How is the claimant’s gender recorded for payroll purposes?" + + choose "Male" + + click_on "Save and continue" + + expect(page).to have_content("Claim decision") + + visit admin_claim_tasks_path(fe_claim) + + click_on "How is the claimant’s gender recorded for payroll purposes?" + + choose "Male" + + click_on "Save and continue" + + expect(page).to have_content("Claim decision") + end end