diff --git a/app/helpers/admin/claims_helper.rb b/app/helpers/admin/claims_helper.rb index e91e6ff0b6..dab5855f56 100644 --- a/app/helpers/admin/claims_helper.rb +++ b/app/helpers/admin/claims_helper.rb @@ -116,7 +116,7 @@ def matching_attributes(first_claim, second_claim) def identity_confirmation_task_claim_verifier_match_status_tag(claim) task = claim.tasks.detect { |t| t.name == "identity_confirmation" } - if task.nil? || task.claim_verifier_match.nil? + if task.nil? status = "Unverified" status_colour = "grey" elsif task.passed? diff --git a/app/models/automated_checks/claim_verifiers/identity.rb b/app/models/automated_checks/claim_verifiers/identity.rb index c6d31d8cc3..2bd9f5d9bc 100644 --- a/app/models/automated_checks/claim_verifiers/identity.rb +++ b/app/models/automated_checks/claim_verifiers/identity.rb @@ -18,9 +18,7 @@ def perform return unless awaiting_task?(TASK_NAME) # Order of matching matters so that subsequent conditions in methods fall through to execute the right thing - no_match || - partial_match || - complete_match + auto_pass || no_match || partial_match || complete_match end private @@ -28,6 +26,17 @@ def perform attr_accessor :admin_user, :claim attr_reader :dqt_teacher_status + def auto_pass + 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) @dqt_teacher_status = if dqt_teacher_status.instance_of?(Array) dqt_teacher_status.first 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 419870e3f6..0eb9758c2f 100644 --- a/app/models/policies/further_education_payments.rb +++ b/app/models/policies/further_education_payments.rb @@ -10,6 +10,7 @@ module FurtherEducationPayments MIN_QA_THRESHOLD = 10 VERIFIERS = [ + AutomatedChecks::ClaimVerifiers::Identity, AutomatedChecks::ClaimVerifiers::ProviderVerification, AutomatedChecks::ClaimVerifiers::Employment ] @@ -39,5 +40,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/models/task.rb b/app/models/task.rb index fe3d9d7af5..b6d2f46682 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -47,4 +47,8 @@ class Task < ApplicationRecord def to_param name end + + def identity_confirmation? + name == "identity_confirmation" + end end diff --git a/app/views/admin/tasks/_task_outcome.html.erb b/app/views/admin/tasks/_task_outcome.html.erb index 2f6d695684..21fe35d047 100644 --- a/app/views/admin/tasks/_task_outcome.html.erb +++ b/app/views/admin/tasks/_task_outcome.html.erb @@ -10,6 +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 task.identity_confirmation? && 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/app/views/admin/tasks/identity_confirmation.html.erb b/app/views/admin/tasks/identity_confirmation.html.erb index 2efe3073c6..0a31d5edbf 100644 --- a/app/views/admin/tasks/identity_confirmation.html.erb +++ b/app/views/admin/tasks/identity_confirmation.html.erb @@ -10,7 +10,7 @@

<%= @current_task_name.humanize %>

- <% unless @claim.identity_verified? %> + <% unless @claim.identity_verified? || @tasks_presenter.identity_confirmation.empty? %>
<%= render "admin/claims/answers", answers: @tasks_presenter.identity_confirmation %>
diff --git a/spec/forms/journeys/further_education_payments/provider/verify_claim_form_spec.rb b/spec/forms/journeys/further_education_payments/provider/verify_claim_form_spec.rb index 4e99995eda..0f1422b821 100644 --- a/spec/forms/journeys/further_education_payments/provider/verify_claim_form_spec.rb +++ b/spec/forms/journeys/further_education_payments/provider/verify_claim_form_spec.rb @@ -332,10 +332,8 @@ ) end - it "creates the provider verification task" do - task = claim.reload.tasks.last - - expect(task.name).to eq("provider_verification") + it "creates a provider verification task" do + task = claim.reload.tasks.find_by(name: "provider_verification") expect(task.created_by.email).to eq( "seymour.skinner@springfield-elementary.edu" diff --git a/spec/helpers/admin/claims_helper_spec.rb b/spec/helpers/admin/claims_helper_spec.rb index 432dfb5ae7..daddd44ee1 100644 --- a/spec/helpers/admin/claims_helper_spec.rb +++ b/spec/helpers/admin/claims_helper_spec.rb @@ -227,7 +227,61 @@ end end - context "with task" do + context "with task passed nil" do + let(:claim_tasks) do + [ + build( + :task, + claim_verifier_match: task_claim_verifier_match, + name: "identity_confirmation", + passed: nil + ) + ] + end + + context "with task claim verifier match any" do + let(:task_claim_verifier_match) { :any } + + it "returns partial match status tag" do + expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("Partial match") + expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("govuk-tag app-task-list__task-completed") + expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("govuk-tag--yellow") + end + end + + context "with task claim verifier match none" do + let(:task_claim_verifier_match) { :none } + + it "returns no match status tag" do + expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("No match") + expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("govuk-tag app-task-list__task-completed") + expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("govuk-tag--red") + end + end + end + + # TODO: Don't think this condition is ever used as identity confirmation task is never failed + # However adding this purely for coverage of the condition that is available + context "with task passed false" do + let(:claim_tasks) do + [ + build( + :task, + claim_verifier_match: nil, + name: "identity_confirmation", + passed: false + ) + ] + end + + it "returns failed task status tag" do + expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("Failed") + expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("govuk-tag app-task-list__task-completed") + expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("govuk-tag--red") + end + end + + context "with task passed true" do let(:claim_tasks) do [ build( @@ -243,9 +297,9 @@ let(:task_claim_verifier_match) { nil } it "returns unverified task status tag" do - expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("Unverified") + expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("Passed") expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("govuk-tag app-task-list__task-completed") - expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("govuk-tag--grey") + expect(identity_confirmation_task_claim_verifier_match_status_tag).to match("govuk-tag--green") end end diff --git a/spec/models/automated_checks/claim_verifiers/identity_spec.rb b/spec/models/automated_checks/claim_verifiers/identity_spec.rb index b5e18c3aa4..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 @@ -63,6 +66,64 @@ module ClaimVerifiers } end + describe "#perform with auto pass for FurtherEducationPayments" do + let(:policy) { Policies::FurtherEducationPayments } + let(:data) do + { + dob: claim_arg.date_of_birth, + name: claim_arg.full_name, + nino: claim_arg.national_insurance_number, + trn: claim_arg.eligibility.teacher_reference_number + } + end + + 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 } + + describe "#claim_verifier_match" do + subject(:claim_verifier_match) { identity_confirmation_task.claim_verifier_match } + + it { is_expected.to eq nil } + end + + 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 } + + describe "#passed" do + subject(:passed) { identity_confirmation_task.passed } + + it { is_expected.to eq false } + end + end + + describe "#created_by" do + subject(:created_by) { identity_confirmation_task.created_by } + + it { is_expected.to eq nil } + end + + describe "#manual" do + subject(:manual) { identity_confirmation_task.manual } + + it { is_expected.to eq false } + end + end + end + describe "#perform" do subject(:perform) { identity.perform } @@ -553,7 +614,7 @@ module ClaimVerifiers national_insurance_number: "QQ100000C", reference: "AB123456", surname: "ELIGIBLE", - tasks: [build(:task, name: :identity_confirmation)], + tasks: [build(:task, name: :identity_confirmation, claim_verifier_match: :all)], eligibility_attributes: {teacher_reference_number: "1234567"} ) end @@ -568,7 +629,7 @@ module ClaimVerifiers describe "#claim_verifier_match" do subject(:claim_verifier_match) { identity_confirmation_task.claim_verifier_match } - it { is_expected.to eq nil } + it { is_expected.to eq "all" } end describe "#created_by" do