diff --git a/app/models/claim.rb b/app/models/claim.rb index a5772505a2..063a3da5b7 100644 --- a/app/models/claim.rb +++ b/app/models/claim.rb @@ -475,14 +475,14 @@ def same_claimant?(other_claim) end end - def one_login_idv_mismatch? - !one_login_idv_name_match? || !one_login_idv_dob_match? - end - def one_login_idv_match? one_login_idv_name_match? && one_login_idv_dob_match? end + def one_login_idv_mismatch? + !one_login_idv_match? + end + def awaiting_provider_verification? return false unless has_further_education_policy? @@ -500,7 +500,8 @@ def attributes_flagged_by_risk_indicator private def one_login_idv_name_match? - onelogin_idv_full_name.downcase == "#{first_name.downcase} #{surname.downcase}" + /\A#{first_name.strip.downcase} /.match?(onelogin_idv_full_name.strip.downcase) && + / #{surname.strip.downcase}\z/.match?(onelogin_idv_full_name.strip.downcase) end def one_login_idv_dob_match? diff --git a/spec/models/claim_spec.rb b/spec/models/claim_spec.rb index d50966b4cf..47a605654a 100644 --- a/spec/models/claim_spec.rb +++ b/spec/models/claim_spec.rb @@ -1478,4 +1478,51 @@ expect(policy).to have_received(:decision_deadline_date).with(claim) end end + + describe "#one_login_idv_match?" do + context "space in first name" do + before do + subject.onelogin_idv_full_name = "A B C" + subject.first_name = "A B" + subject.surname = "C" + + subject.onelogin_idv_date_of_birth = Date.today + subject.date_of_birth = Date.today + end + + it "matches" do + expect(subject).to be_one_login_idv_match + end + end + + context "close match" do + before do + subject.onelogin_idv_full_name = "A B C" + subject.first_name = "AA B" + subject.surname = "C" + + subject.onelogin_idv_date_of_birth = Date.today + subject.date_of_birth = Date.today + end + + it "does not match" do + expect(subject).not_to be_one_login_idv_match + end + end + + context "not a match" do + before do + subject.onelogin_idv_full_name = "A B" + subject.first_name = "Z" + subject.surname = "B" + + subject.onelogin_idv_date_of_birth = Date.today + subject.date_of_birth = Date.today + end + + it "does not match" do + expect(subject).not_to be_one_login_idv_match + end + end + end end