From a9b3884830a10b3a9e49fea379e0694367ae7de4 Mon Sep 17 00:00:00 2001 From: Kenneth Lee Date: Fri, 6 Sep 2024 18:08:48 +0100 Subject: [PATCH] Delegate to policy to decide auto pass logic and include failure --- .../claim_verifiers/identity.rb | 9 ++++++- app/models/base_policy.rb | 4 +++ .../policies/further_education_payments.rb | 4 +++ app/views/admin/tasks/_task_outcome.html.erb | 4 +-- .../claim_verifiers/identity_spec.rb | 25 ++++++++++++++++--- 5 files changed, 39 insertions(+), 7 deletions(-) diff --git a/app/models/automated_checks/claim_verifiers/identity.rb b/app/models/automated_checks/claim_verifiers/identity.rb index 0ccb183f7e..2bd9f5d9bc 100644 --- a/app/models/automated_checks/claim_verifiers/identity.rb +++ b/app/models/automated_checks/claim_verifiers/identity.rb @@ -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) + when :skip + nil + end end def dqt_teacher_status=(dqt_teacher_status) diff --git a/app/models/base_policy.rb b/app/models/base_policy.rb index 7ce56a6c5d..a551f5d9e8 100644 --- a/app/models/base_policy.rb +++ b/app/models/base_policy.rb @@ -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 diff --git a/app/models/policies/further_education_payments.rb b/app/models/policies/further_education_payments.rb index 8f08f88457..ddfa5bcc6b 100644 --- a/app/models/policies/further_education_payments.rb +++ b/app/models/policies/further_education_payments.rb @@ -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 + end end end diff --git a/app/views/admin/tasks/_task_outcome.html.erb b/app/views/admin/tasks/_task_outcome.html.erb index 88a108b089..56b1e1ac5e 100644 --- a/app/views/admin/tasks/_task_outcome.html.erb +++ b/app/views/admin/tasks/_task_outcome.html.erb @@ -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) %> <% else %> This task was performed by an automated check on <%= l(task.created_at) %> <% end %> diff --git a/spec/models/automated_checks/claim_verifiers/identity_spec.rb b/spec/models/automated_checks/claim_verifiers/identity_spec.rb index b68e04f3b8..13c271ec20 100644 --- a/spec/models/automated_checks/claim_verifiers/identity_spec.rb +++ b/spec/models/automated_checks/claim_verifiers/identity_spec.rb @@ -27,6 +27,8 @@ module ClaimVerifiers ) end + let(:identity_confirmed_with_onelogin) { nil } + let(:claim_arg) do claim = create( :claim, @@ -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 @@ -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 } @@ -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