Skip to content

Commit

Permalink
Delegate to policy to decide auto pass logic and include failure
Browse files Browse the repository at this point in the history
  • Loading branch information
kenfodder committed Sep 6, 2024
1 parent da13c20 commit a9b3884
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 7 deletions.
9 changes: 8 additions & 1 deletion app/models/automated_checks/claim_verifiers/identity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ def perform
attr_reader :dqt_teacher_status

def auto_pass
create_task(match: nil, passed: true) if claim.policy.further_education_payments?
case claim.policy.auto_pass_identity_confirmation_task(claim)
when :pass
create_task(match: nil, passed: true)
when :fail
create_task(match: nil, passed: false)

This comment has been minimized.

Copy link
@kenfodder

kenfodder Sep 6, 2024

Author Contributor

This gives the ability to fail the task here and not proceed to other matching, use :skip to allow it to continue with the DQT checks.

when :skip
nil
end
end

def dqt_teacher_status=(dqt_teacher_status)
Expand Down
4 changes: 4 additions & 0 deletions app/models/base_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,8 @@ def international_relocation_payments?
def further_education_payments?
to_s == "FurtherEducationPayments"
end

def auto_pass_identity_confirmation_task(claim)
:skip
end
end
4 changes: 4 additions & 0 deletions app/models/policies/further_education_payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,9 @@ def verification_due_date_for_claim(claim)
def duplicate_claim?(claim)
Claim::MatchingAttributeFinder.new(claim).matching_claims.exists?
end

def auto_pass_identity_confirmation_task(claim)
claim.identity_confirmed_with_onelogin? ? :pass : :fail

This comment has been minimized.

Copy link
@kenfodder

kenfodder Sep 6, 2024

Author Contributor

If for some reason this FE claim was not identity_confirmed_with_onelogin with true then we want to :fail the task as we don't want it to fall back DQT matching, so it short circuits at only the auto_pass check.

end
end
end
4 changes: 2 additions & 2 deletions app/views/admin/tasks/_task_outcome.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
This task was performed by <%= user_details(task.created_by, include_line_break: false) %> on <%= l(task.updated_at) %>
<% elsif task.created_by %>
This task was performed by an automated check uploaded by <%= user_details(task.created_by, include_line_break: false) %> on <%= l(task.created_at) %>
<% elsif onelogin_auth_at = task.claim.onelogin_auth_at %>
This task was performed by GOV.UK One Login on <%= l(onelogin_auth_at) %>
<% elsif task.claim.identity_confirmed_with_onelogin? %>
This task was performed by GOV.UK One Login on <%= l(task.claim.onelogin_idv_at) %>

This comment has been minimized.

Copy link
@kenfodder

kenfodder Sep 6, 2024

Author Contributor

onelogin_idv_at is correct timestamp to use and identity_confirmed_with_onelogin is definitive if OL actually verified the identity.

<% else %>
This task was performed by an automated check on <%= l(task.created_at) %>
<% end %>
Expand Down
25 changes: 21 additions & 4 deletions spec/models/automated_checks/claim_verifiers/identity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ module ClaimVerifiers
)
end

let(:identity_confirmed_with_onelogin) { nil }

let(:claim_arg) do
claim = create(
:claim,
Expand All @@ -36,7 +38,8 @@ module ClaimVerifiers
national_insurance_number: "QQ100000C",
reference: "AB123456",
surname: "ELIGIBLE",
policy: policy
policy: policy,
identity_confirmed_with_onelogin: identity_confirmed_with_onelogin
)

policy_underscored = policy.to_s.underscore
Expand Down Expand Up @@ -77,6 +80,8 @@ module ClaimVerifiers
subject(:perform) { identity.perform }

describe "identity confirmation task" do
let(:identity_confirmed_with_onelogin) { true }

subject(:identity_confirmation_task) { claim_arg.tasks.find_by(name: "identity_confirmation") }

before { perform }
Expand All @@ -87,10 +92,22 @@ module ClaimVerifiers
it { is_expected.to eq nil }
end

describe "#passed" do
subject(:passed) { identity_confirmation_task.passed }
context "identity_confirmed_with_onelogin true" do
describe "#passed" do
subject(:passed) { identity_confirmation_task.passed }

it { is_expected.to eq true }
end
end

context "identity_confirmed_with_onelogin false" do
let(:identity_confirmed_with_onelogin) { false }

it { is_expected.to eq true }
describe "#passed" do
subject(:passed) { identity_confirmation_task.passed }

it { is_expected.to eq false }
end
end

describe "#created_by" do
Expand Down

0 comments on commit a9b3884

Please sign in to comment.