Skip to content

Commit

Permalink
OL name matches via regexp
Browse files Browse the repository at this point in the history
  • Loading branch information
asmega committed Dec 5, 2024
1 parent fe26058 commit 45e400f
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/models/claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand All @@ -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?
Expand Down
47 changes: 47 additions & 0 deletions spec/models/claim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 45e400f

Please sign in to comment.