Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add name and dob check to matching claims #3161

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/models/claim/matching_attribute_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
58 changes: 55 additions & 3 deletions spec/models/claim/matching_attribute_finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: "[email protected]",
bank_account_number: "34682151",
Expand All @@ -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: "[email protected]",
bank_account_number: "34682151",
Expand All @@ -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: "[email protected]",
bank_account_number: "34682151",
Expand All @@ -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: "[email protected]",
bank_account_number: "34682151",
Expand Down Expand Up @@ -172,6 +184,39 @@

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

describe "matching_claims - blank trn" do
Expand All @@ -193,7 +238,8 @@
:claim,
:submitted,
policy: policy,
eligibility: eligibility
eligibility: eligibility,
surname: Faker::Name.last_name
)
}

Expand Down Expand Up @@ -221,7 +267,8 @@
:claim,
:submitted,
policy: policy,
eligibility: eligibility
eligibility: eligibility,
surname: Faker::Name.last_name
)
}

Expand Down Expand Up @@ -253,7 +300,8 @@
:claim,
:submitted,
policy: policy,
eligibility: eligibility
eligibility: eligibility,
surname: Faker::Name.last_name
)
}

Expand All @@ -266,6 +314,8 @@
it "returns the attributes that match" do
source_claim = create(
:claim,
first_name: "genghis",
surname: "khan",
email_address: "[email protected]",
national_insurance_number: "QQ891011C",
bank_account_number: "34682151",
Expand All @@ -277,6 +327,8 @@

other_claim = create(
:claim,
first_name: "genghis",
surname: "khan2",
email_address: "[email protected]",
national_insurance_number: "QQ891011C",
bank_account_number: "11111111",
Expand Down
2 changes: 1 addition & 1 deletion spec/models/claim_checking_tasks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion spec/support/admin_view_claim_feature_shared_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
:claim,
:submitted,
policy: policy,
eligibility: eligibility
eligibility: eligibility,
first_name: Faker::Name.first_name,
surname: Faker::Name.last_name
)
}

Expand Down