Skip to content

Commit

Permalink
Merge pull request #3362 from DFE-Digital/LUPEYALPHA-1231-EY-student-…
Browse files Browse the repository at this point in the history
…loan-plan-task

[LUPEYALPHA-1231] EY student loan plan task
  • Loading branch information
rjlynch authored Nov 1, 2024
2 parents 7d37d79 + 1bb9485 commit 13d2ef0
Show file tree
Hide file tree
Showing 17 changed files with 127 additions and 8 deletions.
6 changes: 5 additions & 1 deletion app/controllers/claims_form_callbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def on_tid_route?
end

def journey_requires_student_loan_details?
student_loans_journey? || additional_payments_journey? || get_a_teacher_relocation_payment_journey? || further_education_payments_journey?
student_loans_journey? || additional_payments_journey? || get_a_teacher_relocation_payment_journey? || further_education_payments_journey? || early_years_payments_practitioner_journey?
end

def student_loans_journey?
Expand All @@ -139,4 +139,8 @@ def get_a_teacher_relocation_payment_journey?
def further_education_payments_journey?
current_journey_routing_name == "further-education-payments"
end

def early_years_payments_practitioner_journey?
current_journey_routing_name == "early-years-payment-practitioner"
end
end
3 changes: 2 additions & 1 deletion app/jobs/student_loan_plan_check_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ class StudentLoanPlanCheckJob < ApplicationJob
APPLICABLE_POLICIES = [
Policies::EarlyCareerPayments,
Policies::LevellingUpPremiumPayments,
Policies::FurtherEducationPayments
Policies::FurtherEducationPayments,
Policies::EarlyYearsPayments
].freeze

def perform
Expand Down
4 changes: 4 additions & 0 deletions app/models/claim_checking_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ def applicable_task_names
Policies::InternationalRelocationPayments::ClaimCheckingTasks
.new(claim)
.applicable_task_names
when Policies::EarlyYearsPayments
Policies::EarlyYearsPayments::ClaimCheckingTasks
.new(claim)
.applicable_task_names
else
Task::NAMES.dup.tap do |task_names|
task_names.delete("previous_payment")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Journeys
module EarlyYearsPayment
module Practitioner
class AnswersStudentLoansDetailsUpdater < Journeys::AnswersStudentLoansDetailsUpdater
end
end
end
end
6 changes: 5 additions & 1 deletion app/models/policies/early_years_payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module EarlyYearsPayments
MIN_QA_THRESHOLD = 10

VERIFIERS = [
AutomatedChecks::ClaimVerifiers::StudentLoanPlan # TODO - spec
AutomatedChecks::ClaimVerifiers::StudentLoanPlan
]

# Attributes to delete from claims submitted before the current academic
Expand Down Expand Up @@ -64,5 +64,9 @@ def notify_reply_to_id
def award_amount
1_000
end

def auto_check_student_loan_plan_task?
true
end
end
end
29 changes: 29 additions & 0 deletions app/models/policies/early_years_payments/claim_checking_tasks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

module Policies
module EarlyYearsPayments
class ClaimCheckingTasks
attr_reader :claim

def initialize(claim)
@claim = claim
end

delegate :policy, to: :claim

def applicable_task_names
tasks = []

tasks << "student_loan_plan" if claim.submitted_without_slc_data?

tasks
end

private

def matching_claims
@matching_claims ||= Claim::MatchingAttributeFinder.new(claim).matching_claims
end
end
end
end
1 change: 1 addition & 0 deletions spec/features/admin/upload_slc_data_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
create(:journey_configuration, :student_loans) # used by StudentLoanAmountCheckJob
create(:journey_configuration, :early_career_payments)
create(:journey_configuration, :further_education_payments)
create(:journey_configuration, :early_years_payment_provider_start)
sign_in_as_service_operator
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
:claim,
policy: Policies::EarlyYearsPayments,
reference: "foo",
practitioner_email_address: "user@example.com"
practitioner_email_address: "practitioner@example.com"
)
end
let(:otp_code) { "123456" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
let(:claim) { Claim.last }

scenario "Happy path" do
when_student_loan_data_exists
when_early_years_payment_provider_authenticated_journey_submitted
when_early_years_payment_practitioner_journey_configuration_exists

Expand Down Expand Up @@ -83,6 +84,7 @@

expect(claim.eligibility.practitioner_claim_started_at).to be_present
expect(claim.reload.submitted_at).to be_present
expect(claim.student_loan_plan).to eq "plan_1"

# check answers were saved on the claim
expect(claim.reload.national_insurance_number).to eq "PX321499A"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
:claim,
policy: Policies::EarlyYearsPayments,
reference: "foo",
practitioner_email_address: "user@example.com"
practitioner_email_address: "practitioner@example.com"
)
end
let(:otp_code) { "123456" }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
require "rails_helper"

RSpec.feature "Early Years Payments Student Loan Plan" do
include ActionView::Helpers::NumberHelper

let(:claim) { Claim.last }
let(:magic_link) { mail[:personalisation].unparsed_value[:magic_link] }
let(:mail) { ActionMailer::Base.deliveries.last }

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

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

sign_in_as_service_operator

visit admin_claim_tasks_path(claim)
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_early_years_practitioner_claim_submitted

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

sign_in_as_service_operator

visit admin_claim_tasks_path(claim)
expect(page).not_to have_content "Student loan plan"
end
end
10 changes: 10 additions & 0 deletions spec/jobs/student_loan_plan_check_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

before do
create(:journey_configuration, :further_education_payments)
create(:journey_configuration, :early_years_payment_provider_start)
end

let!(:claim) { create(:claim, claim_status, academic_year:, policy: Policies::LevellingUpPremiumPayments) }
Expand All @@ -23,6 +24,15 @@
end
end

it "includes all applicable policies" do
expect(StudentLoanPlanCheckJob::APPLICABLE_POLICIES).to eq [
Policies::EarlyCareerPayments,
Policies::LevellingUpPremiumPayments,
Policies::FurtherEducationPayments,
Policies::EarlyYearsPayments
]
end

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) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
let!(:journey_configuration_tslr) { create(:journey_configuration, :student_loans) }
let!(:journey_configuration_ecp_lupp) { create(:journey_configuration, :additional_payments) }
let!(:journey_configuration_fe) { create(:journey_configuration, :further_education_payments) }
let!(:journey_configuration_ey) { create(:journey_configuration, :early_years_payment_provider_start) }

before { @signed_in_user = sign_in_as_service_operator }

Expand Down
2 changes: 1 addition & 1 deletion spec/support/admin_view_claim_feature_shared_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def expect_page_to_have_policy_sections(policy)
when Policies::FurtherEducationPayments
["Identity confirmation", "Provider verification", "Student loan plan", "Decision"]
when Policies::EarlyYearsPayments
["Identity confirmation", "Qualifications", "Census subjects taught", "Employment", "Decision"]
["Student loan plan", "Decision"]
else
raise "Unimplemented policy: #{policy}"
end
Expand Down
21 changes: 20 additions & 1 deletion spec/support/steps/early_years_practitioner_journey.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def when_personal_details_entered_up_to_address
visit "/early-years-payment-practitioner/find-reference?skip_landing_page=true&email=user@example.com"
visit "/early-years-payment-practitioner/find-reference?skip_landing_page=true&email=practitioner@example.com"
fill_in "Claim reference number", with: claim.reference
click_button "Submit"

Expand Down Expand Up @@ -35,3 +35,22 @@ def when_personal_details_entered_up_to_email_address
fill_in "claim-one-time-password-field", with: otp_in_mail_sent
click_on "Confirm"
end

def when_early_years_practitioner_claim_submitted
when_early_years_payment_practitioner_journey_configuration_exists
when_early_years_payment_provider_authenticated_journey_submitted
when_personal_details_entered_up_to_email_address

choose "No"
click_on "Continue"

fill_in "Name on your account", with: "Jo Bloggs"
fill_in "Sort code", with: "123456"
fill_in "Account number", with: "87654321"
click_on "Continue"

choose "Female"
click_on "Continue"

perform_enqueued_jobs { click_on "Accept and send" }
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
def when_early_years_payment_provider_authenticated_journey_ready_to_submit
nursery = EligibleEyProvider.last || create(:eligible_ey_provider, primary_key_contact_email_address: "[email protected]")

visit magic_link
check "I confirm that I have obtained consent from my employee and have provided them with the relevant privacy notice."
click_button "Continue"
Expand Down
2 changes: 1 addition & 1 deletion spec/support/steps/eligible_ey_providers.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
def when_eligible_ey_provider_exists
create(:eligible_ey_provider, primary_key_contact_email_address: "[email protected]", secondary_contact_email_address: "[email protected]")
create(:eligible_ey_provider, primary_key_contact_email_address: "[email protected]", secondary_contact_email_address: "[email protected]") unless EligibleEyProvider.any?
end

0 comments on commit 13d2ef0

Please sign in to comment.