Skip to content

Commit

Permalink
Merge pull request #3176 from DFE-Digital/fe-blank-trn-matching-bug
Browse files Browse the repository at this point in the history
LUPEYALPHA-1015 - FE claims with no TRN aren't considered matching other claims with no TRN
  • Loading branch information
kenfodder authored Sep 13, 2024
2 parents 63de394 + 2384917 commit a4f1146
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/models/claim/matching_attribute_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def matching_claims
# Claim attributes
CLAIM_ATTRIBUTE_GROUPS_TO_MATCH.each do |attributes|
vals = values_for_attributes(@source_claim, attributes)

next if vals.blank?

concatenated_columns = "CONCAT(#{attributes.join(",")})"
Expand All @@ -39,12 +38,13 @@ def matching_claims
# Eligibility attributes
eligibility_ids = eligibility_attributes_groups_to_match.map { |attributes|
vals = values_for_attributes(@source_claim.eligibility, attributes)
concatenated_columns = "CONCAT(#{attributes.join(",")})"
next if vals.blank?

concatenated_columns = "CONCAT(#{attributes.join(",")})"
policies_to_find_matches.map { |policy|
policy::Eligibility.where("LOWER(#{concatenated_columns}) = LOWER(?)", vals.join)
}
}.flatten.map(&:id)
}.compact.flatten.map(&:id)

eligibility_match_query = Claim.where(eligibility_id: eligibility_ids)
match_queries = match_queries.or(eligibility_match_query)
Expand Down
88 changes: 88 additions & 0 deletions spec/models/claim/matching_attribute_finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,92 @@
expect(matching_claims).to be_empty
end
end

describe "matching_claims - blank trn" do
let(:policy) { Policies::FurtherEducationPayments }

let!(:source_claim) {
eligibility = create(:further_education_payments_eligibility, :eligible)
create(
:claim,
:submitted,
policy: policy,
eligibility: eligibility
)
}

let!(:other_claim) {
eligibility = create(:further_education_payments_eligibility, :eligible)
create(
:claim,
:submitted,
policy: policy,
eligibility: eligibility
)
}

subject(:matching_claims) { Claim::MatchingAttributeFinder.new(source_claim).matching_claims }

it { is_expected.to be_empty }
end

describe "matching_claims - same trn" do
let(:policy) { Policies::FurtherEducationPayments }

let!(:source_claim) {
eligibility = create(:further_education_payments_eligibility, :eligible, :with_trn)
create(
:claim,
:submitted,
policy: policy,
eligibility: eligibility
)
}

let!(:other_claim) {
eligibility = create(:further_education_payments_eligibility, :eligible, teacher_reference_number: source_claim.eligibility.teacher_reference_number)
create(
:claim,
:submitted,
policy: policy,
eligibility: eligibility
)
}

subject(:matching_claims) { Claim::MatchingAttributeFinder.new(source_claim).matching_claims }

it { is_expected.to eq [other_claim] }
end

describe "matching_claims - blank trn, another field group with same contract type, blank provision_search" do
before do
stub_const("Policies::FurtherEducationPayments::ELIGIBILITY_MATCHING_ATTRIBUTES", [["teacher_reference_number"], ["provision_search", "contract_type"]])
end

let(:policy) { Policies::FurtherEducationPayments }

let!(:source_claim) {
eligibility = create(:further_education_payments_eligibility, :eligible, contract_type: "permanent", provision_search: nil)
create(
:claim,
:submitted,
policy: policy,
eligibility: eligibility
)
}

let!(:other_claim) {
eligibility = create(:further_education_payments_eligibility, :eligible, contract_type: "permanent", provision_search: nil)
create(
:claim,
:submitted,
policy: policy,
eligibility: eligibility
)
}

subject(:matching_claims) { Claim::MatchingAttributeFinder.new(source_claim).matching_claims }

it { is_expected.to eq [other_claim] }
end
end
8 changes: 6 additions & 2 deletions spec/support/admin_view_claim_feature_shared_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
}

let!(:multiple_claim) {
eligibility = create(:"#{policy.to_s.underscore}_eligibility", :eligible)
eligibility = if policy == Policies::FurtherEducationPayments
create(:"#{policy.to_s.underscore}_eligibility", :eligible, :with_trn)
else
create(:"#{policy.to_s.underscore}_eligibility", :eligible)
end
create(
:claim,
:submitted,
Expand Down Expand Up @@ -158,7 +162,7 @@ def expect_page_to_have_policy_sections(policy)
when Policies::InternationalRelocationPayments
["Identity confirmation", "Visa", "Arrival date", "Employment", "Employment contract", "Employment start", "Subject", "Teaching hours", "Decision"]
when Policies::FurtherEducationPayments
["Identity confirmation", "Provider verification", "Student loan plan", "Payroll details", "Matching details", "Decision"]
["Identity confirmation", "Provider verification", "Student loan plan", "Payroll details", "Decision"]
else
raise "Unimplemented policy: #{policy}"
end
Expand Down

0 comments on commit a4f1146

Please sign in to comment.