Skip to content

Commit

Permalink
When no entry in SLC data, do not create task (shows as incomplete on…
Browse files Browse the repository at this point in the history
… admin view)
  • Loading branch information
alkesh committed Oct 9, 2024
1 parent 02fd20b commit fbe2c50
Show file tree
Hide file tree
Showing 9 changed files with 247 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def awaiting_task?
def no_student_loan_data_entry
return if student_loans_data.any?

create_task(match: nil)
create_note(match: nil)
end

def student_loan_data_exists
Expand Down
3 changes: 2 additions & 1 deletion app/models/policies/further_education_payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ module FurtherEducationPayments
VERIFIERS = [
AutomatedChecks::ClaimVerifiers::Identity,
AutomatedChecks::ClaimVerifiers::ProviderVerification,
AutomatedChecks::ClaimVerifiers::Employment
AutomatedChecks::ClaimVerifiers::Employment,
AutomatedChecks::ClaimVerifiers::StudentLoanPlan
]

# Options shown to admins when rejecting a claim
Expand Down
1 change: 1 addition & 0 deletions app/views/admin/tasks/student_loan_plan.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<% if @task.persisted? %>
<%= render "task_outcome", task: @task %>
<% else %>
<%= render "admin/tasks/notes", notes: @notes, display_description: false %>
<div class="govuk-inset-text task-outcome">
<p class="govuk-body">
<%= task_status_content_tag(status_colour: "grey", status: "Incomplete") %>
Expand Down
6 changes: 3 additions & 3 deletions spec/features/admin/upload_slc_data_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
expect(claim.has_student_loan).to eq true

claim = ecp_claim_no_slc_data
then_the_student_loan_plan_task_should_show_as(state: "No data", for_claim: claim)
then_the_student_loan_plan_task_should_show_as(state: "Incomplete", for_claim: claim)
expect(claim.reload.student_loan_plan).to be nil # this was "not_applicable" before LUPEYALPHA-1031
expect(claim.has_student_loan).to be nil # this was false before LUPEYALPHA-1031

Expand All @@ -133,7 +133,7 @@
expect(claim.has_student_loan).to eq true

claim = fe_claim_no_slc_data_nil_submitted_using_slc_data
then_the_student_loan_plan_task_should_show_as(state: "No data", for_claim: claim)
then_the_student_loan_plan_task_should_show_as(state: "Incomplete", for_claim: claim)
expect(claim.reload.student_loan_plan).to be nil
expect(claim.has_student_loan).to be nil

Expand All @@ -148,7 +148,7 @@
expect(claim.has_student_loan).to eq true

claim = fe_claim_no_slc_data
then_the_student_loan_plan_task_should_show_as(state: "No data", for_claim: claim)
then_the_student_loan_plan_task_should_show_as(state: "Incomplete", for_claim: claim)
expect(claim.reload.student_loan_plan).to be nil
expect(claim.has_student_loan).to be nil
end
Expand Down
39 changes: 39 additions & 0 deletions spec/features/further_education_payments/student_loan_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
require "rails_helper"

RSpec.feature "Further education payments" do
include ActionView::Helpers::NumberHelper

let(:college) { create(:school, :further_education, :fe_eligible) }
let(:claim) { Claim.last }

scenario "student loan data does not exist on submission" do
when_further_education_journey_ready_to_submit

perform_enqueued_jobs { click_on "Accept and send" }

expect(claim.tasks.where(name: "student_loan_plan")).to be_empty

sign_in_as_service_operator

visit admin_claims_path
find("a[href='#{admin_claim_tasks_path(claim)}']").click
within "li.student_loan_plan" do
expect(page).to have_content "Incomplete"
end
end

scenario "student loan data does exist on submission" do
when_student_loan_data_exists
when_further_education_journey_ready_to_submit

perform_enqueued_jobs { click_on "Accept and send" }

expect(claim.student_loan_plan).to eq "plan_1"

sign_in_as_service_operator

visit admin_claims_path
find("a[href='#{admin_claim_tasks_path(claim)}']").click
expect(page).not_to have_content "Student loan plan"
end
end
80 changes: 24 additions & 56 deletions spec/jobs/student_loan_plan_check_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,43 @@
create(:journey_configuration, :further_education_payments)
end

let(:claim) { create(:claim, claim_status, academic_year:, policy: Policies::LevellingUpPremiumPayments) }
let!(:claim) { create(:claim, claim_status, academic_year:, policy: Policies::LevellingUpPremiumPayments) }
let(:claim_status) { :submitted }

let(:academic_year) { journey_configuration.current_academic_year }
let(:journey_configuration) { create(:journey_configuration, :additional_payments) }
let(:student_loan_plan_claim_verifier) { instance_double(AutomatedChecks::ClaimVerifiers::StudentLoanPlan, perform: true) }

describe "#perform" do
before do
allow(ClaimStudentLoanDetailsUpdater).to receive(:call)
end

shared_examples :skip_check do
before do
allow(AutomatedChecks::ClaimVerifiers::StudentLoanPlan).to receive(:new)
end

shared_examples :student_loan_plan_claim_verifier_not_called do
it "excludes the claim from the check", :aggregate_failures do
expect(ClaimStudentLoanDetailsUpdater).not_to receive(:call).with(claim)
expect(AutomatedChecks::ClaimVerifiers::StudentLoanPlan).not_to receive(:new).with(claim: claim)
expect(ClaimStudentLoanDetailsUpdater).not_to receive(:call)
expect(AutomatedChecks::ClaimVerifiers::StudentLoanPlan).not_to receive(:new)
perform_job
end
end

context "when the previous student loan plan check was run manually" do
context "when the previous student loan plan check was run manually" do # not sure it's possible to do this any more
let!(:previous_task) { create(:task, claim: claim, name: "student_loan_plan", claim_verifier_match: nil, manual: true) }

include_examples :skip_check
include_examples :student_loan_plan_claim_verifier_not_called
end

context "when a claim is not awaiting decision" do
let(:claim_status) { :approved }

include_examples :skip_check
include_examples :student_loan_plan_claim_verifier_not_called
end

context "when a claim was submitted using SLC data" do
before do
claim.update!(submitted_using_slc_data: true)
end

include_examples :skip_check
include_examples :student_loan_plan_claim_verifier_not_called
end

context "when a claim was submitted using the student loan questions" do
context "when a claim was submitted with no SLC data available" do
before do
claim.update!(submitted_using_slc_data: false)
end
Expand All @@ -60,10 +53,9 @@
perform_job
end

it "runs the task" do
expect { perform_job }
.to change { claim.reload.notes.count }
.and change { claim.tasks.count }
it "calls the student loan plan claim verifier" do
expect(AutomatedChecks::ClaimVerifiers::StudentLoanPlan).to receive(:new).with(claim: claim).and_return(student_loan_plan_claim_verifier)
perform_job
end
end

Expand All @@ -80,10 +72,9 @@
perform_job
end

it "runs the task" do
expect { perform_job }
.to change { claim.reload.notes.count }
.and change { claim.tasks.count }
it "calls the student loan plan claim verifier" do
expect(AutomatedChecks::ClaimVerifiers::StudentLoanPlan).to receive(:new).with(claim: claim).and_return(student_loan_plan_claim_verifier)
perform_job
end
end

Expand All @@ -93,10 +84,9 @@
perform_job
end

it "runs the task" do
expect { perform_job }
.to change { claim.reload.notes.count }
.and change { claim.tasks.count }
it "calls the student loan plan claim verifier" do
expect(AutomatedChecks::ClaimVerifiers::StudentLoanPlan).to receive(:new).with(claim: claim).and_return(student_loan_plan_claim_verifier)
perform_job
end
end

Expand All @@ -108,44 +98,22 @@
perform_job
end

it "re-runs the task" do
expect { perform_job }
.to change { claim.reload.notes.count }
.and change { claim.tasks.last.updated_at }
.and not_change { claim.reload.tasks.count }
it "calls the student loan plan claim verifier" do
expect(AutomatedChecks::ClaimVerifiers::StudentLoanPlan).to receive(:new).with(claim: claim).and_return(student_loan_plan_claim_verifier)
perform_job
end
end

context "when the previous student loan plan check outcome was FAILED" do
let!(:previous_task) { create(:task, claim: claim, name: "student_loan_plan", claim_verifier_match: :none, passed: false, manual: false) }

it "does not update the student loan details" do
expect(ClaimStudentLoanDetailsUpdater).not_to receive(:call)
perform_job
end

it "does not re-run the task" do
expect { perform_job }
.to not_change { claim.reload.notes.count }
.and not_change { claim.tasks.last.updated_at }
.and not_change { claim.reload.tasks.count }
end
include_examples :student_loan_plan_claim_verifier_not_called
end

context "when the previous student loan plan check outcome was PASSED" do
let!(:previous_task) { create(:task, claim: claim, name: "student_loan_plan", claim_verifier_match: :all, manual: false) }

it "does not update the student loan details" do
expect(ClaimStudentLoanDetailsUpdater).not_to receive(:call)
perform_job
end

it "does not re-run the task" do
expect { perform_job }
.to not_change { claim.reload.notes.count }
.and not_change { claim.tasks.last.updated_at }
.and not_change { claim.reload.tasks.count }
end
include_examples :student_loan_plan_claim_verifier_not_called
end
end
end
Loading

0 comments on commit fbe2c50

Please sign in to comment.