From 85028d5fea4cc5f7664f6d5c59ed031063243ea1 Mon Sep 17 00:00:00 2001 From: Richard Lynch Date: Fri, 6 Sep 2024 14:25:24 +0100 Subject: [PATCH] Add name and dob check to matching claims A requirement is to trigger a "multiple claims with matching details" warning if there is another claim with a matching name and date of birth. This check is to work across all policies. --- app/models/claim/matching_attribute_finder.rb | 3 +- .../claim/matching_attribute_finder_spec.rb | 45 +++++++++++++++++++ spec/models/claim_checking_tasks_spec.rb | 2 +- ...dmin_view_claim_feature_shared_examples.rb | 4 +- 4 files changed, 51 insertions(+), 3 deletions(-) diff --git a/app/models/claim/matching_attribute_finder.rb b/app/models/claim/matching_attribute_finder.rb index 710601bb92..5ac90fd7f8 100644 --- a/app/models/claim/matching_attribute_finder.rb +++ b/app/models/claim/matching_attribute_finder.rb @@ -4,7 +4,8 @@ class MatchingAttributeFinder CLAIM_ATTRIBUTE_GROUPS_TO_MATCH = [ ["email_address"], ["national_insurance_number"], - ["bank_account_number", "bank_sort_code", "building_society_roll_number"] + ["bank_account_number", "bank_sort_code", "building_society_roll_number"], + ["first_name", "surname", "date_of_birth"] ].freeze def initialize(source_claim) diff --git a/spec/models/claim/matching_attribute_finder_spec.rb b/spec/models/claim/matching_attribute_finder_spec.rb index c1e868a0dd..68c27a4f1c 100644 --- a/spec/models/claim/matching_attribute_finder_spec.rb +++ b/spec/models/claim/matching_attribute_finder_spec.rb @@ -4,6 +4,9 @@ describe "#matching_claims for ECP/LUP claims" do let!(:source_claim) { create(:claim, + first_name: "Genghis", + surname: "Khan", + date_of_birth: Date.new(1162, 5, 31), national_insurance_number: "QQ891011C", email_address: "genghis.khan@mongol-empire.com", bank_account_number: "34682151", @@ -17,6 +20,9 @@ let!(:student_loans_claim) { create(:claim, :submitted, + first_name: "Genghis", + surname: "Khan", + date_of_birth: Date.new(1162, 5, 31), national_insurance_number: "QQ891011C", email_address: "genghis.khan@mongol-empire.com", bank_account_number: "34682151", @@ -30,6 +36,9 @@ let!(:lup_claim) { create(:claim, :submitted, + first_name: "Genghis", + surname: "Khan", + date_of_birth: Date.new(1162, 5, 31), national_insurance_number: "QQ891011C", email_address: "genghis.khan@mongol-empire.com", bank_account_number: "34682151", @@ -50,6 +59,9 @@ describe "#matching_claims" do let(:source_claim) { create(:claim, + first_name: "Genghis", + surname: "Khan", + date_of_birth: Date.new(1162, 5, 31), national_insurance_number: "QQ891011C", email_address: "genghis.khan@mongol-empire.com", bank_account_number: "34682151", @@ -172,5 +184,38 @@ expect(matching_claims).to be_empty end + + it "does not include a claim with a matching name" do + create( + :claim, + :submitted, + first_name: source_claim.first_name, + surname: source_claim.surname + ) + + expect(matching_claims).to be_empty + end + + it "does not include a claim with a matching date of birth" do + create( + :claim, + :submitted, + date_of_birth: source_claim.date_of_birth + ) + + expect(matching_claims).to be_empty + end + + it "includes a claim with a matching name and date of birth" do + claim_with_matching_attributes = create( + :claim, + :submitted, + first_name: source_claim.first_name, + surname: source_claim.surname, + date_of_birth: source_claim.date_of_birth + ) + + expect(matching_claims).to eq([claim_with_matching_attributes]) + end end end diff --git a/spec/models/claim_checking_tasks_spec.rb b/spec/models/claim_checking_tasks_spec.rb index 63a05a1eb2..be7bcf5c55 100644 --- a/spec/models/claim_checking_tasks_spec.rb +++ b/spec/models/claim_checking_tasks_spec.rb @@ -21,7 +21,7 @@ end it "includes a task for payroll gender when a payroll gender task has previously been completed" do - claim.tasks << create(:task, name: "payroll_gender") + create(:task, name: "payroll_gender", claim: claim) expect(checking_tasks.applicable_task_names).to match_array(applicable_tasks + %w[payroll_gender]) end diff --git a/spec/support/admin_view_claim_feature_shared_examples.rb b/spec/support/admin_view_claim_feature_shared_examples.rb index f9bb1f79bf..cc9d7fbb7f 100644 --- a/spec/support/admin_view_claim_feature_shared_examples.rb +++ b/spec/support/admin_view_claim_feature_shared_examples.rb @@ -8,7 +8,9 @@ :claim, :submitted, policy: policy, - eligibility: eligibility + eligibility: eligibility, + first_name: Faker::Name.first_name, + surname: Faker::Name.last_name ) }