Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LUPEYALPHA-955 - Add identity confirmation task to FE that auto passes #3164

Merged
merged 3 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/helpers/admin/claims_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
15 changes: 12 additions & 3 deletions app/models/automated_checks/claim_verifiers/identity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,25 @@ 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

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
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
5 changes: 5 additions & 0 deletions app/models/policies/further_education_payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module FurtherEducationPayments
MIN_QA_THRESHOLD = 10

VERIFIERS = [
AutomatedChecks::ClaimVerifiers::Identity,
AutomatedChecks::ClaimVerifiers::ProviderVerification,
AutomatedChecks::ClaimVerifiers::Employment
]
Expand Down Expand Up @@ -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
4 changes: 4 additions & 0 deletions app/models/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,8 @@ class Task < ApplicationRecord
def to_param
name
end

def identity_confirmation?
name == "identity_confirmation"
end
end
2 changes: 2 additions & 0 deletions app/views/admin/tasks/_task_outcome.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/tasks/identity_confirmation.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<h2 class="govuk-heading-l"><%= @current_task_name.humanize %></h2>
</div>

<% unless @claim.identity_verified? %>
<% unless @claim.identity_verified? || @tasks_presenter.identity_confirmation.empty? %>
<div class="govuk-grid-column-two-thirds">
<%= render "admin/claims/answers", answers: @tasks_presenter.identity_confirmation %>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
"[email protected]"
Expand Down
60 changes: 57 additions & 3 deletions spec/helpers/admin/claims_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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

Expand Down
67 changes: 64 additions & 3 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 All @@ -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 }

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading