Skip to content

Commit

Permalink
Merge branch 'master' into LUPEYALPHA-1061-invalid-reference-number
Browse files Browse the repository at this point in the history
  • Loading branch information
vacabor authored Oct 4, 2024
2 parents de01537 + e188462 commit fc8657d
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 87 deletions.
5 changes: 5 additions & 0 deletions app/controllers/claims_form_callbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ def check_your_answers_after_form_save_success
create_and_save_claim_form
end

def employee_email_after_form_save_failure
session[:slugs].delete("employee-email")
render_template_for_current_slug
end

private

def set_backlink_override_to_current_slug
Expand Down
1 change: 1 addition & 0 deletions app/models/concerns/eligibility_checkable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module EligibilityCheckable

FIRST_COMBINED_ECP_AND_LUP_POLICY_YEAR = AcademicYear.new(2022)
FINAL_COMBINED_ECP_AND_LUP_POLICY_YEAR = AcademicYear.new(2024)
FINAL_LUP_POLICY_YEAR = AcademicYear.new(2025)
COMBINED_ECP_AND_LUP_POLICY_YEARS = FIRST_COMBINED_ECP_AND_LUP_POLICY_YEAR..FINAL_COMBINED_ECP_AND_LUP_POLICY_YEAR
COMBINED_ECP_AND_LUP_POLICY_YEARS_BEFORE_FINAL_YEAR = FIRST_COMBINED_ECP_AND_LUP_POLICY_YEAR...FINAL_COMBINED_ECP_AND_LUP_POLICY_YEAR

Expand Down
12 changes: 10 additions & 2 deletions app/models/journeys/additional_payments_for_teaching.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,16 @@ module AdditionalPaymentsForTeaching
}
}.freeze

def set_a_reminder?(itt_academic_year:, policy_year: configuration.current_academic_year)
return false if policy_year >= EligibilityCheckable::FINAL_COMBINED_ECP_AND_LUP_POLICY_YEAR
def final_policy_year(policy)
{
Policies::EarlyCareerPayments => EligibilityCheckable::FINAL_COMBINED_ECP_AND_LUP_POLICY_YEAR,
Policies::LevellingUpPremiumPayments => EligibilityCheckable::FINAL_LUP_POLICY_YEAR
}[policy]
end

def set_a_reminder?(itt_academic_year:, policy:)
policy_year = configuration.current_academic_year
return false if policy_year >= final_policy_year(policy)

next_year = policy_year + 1
eligible_itt_years = JourneySubjectEligibilityChecker.selectable_itt_years_for_claim_year(next_year)
Expand Down
2 changes: 1 addition & 1 deletion app/views/additional_payments/submissions/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<%= render partial: "submissions/confirmation" %>

<% if journey.set_a_reminder?(itt_academic_year: submitted_claim.eligibility.itt_academic_year) %>
<% if journey.set_a_reminder?(itt_academic_year: submitted_claim.eligibility.itt_academic_year, policy: submitted_claim.policy) %>
<%= render partial: "submissions/reminder" %>
<% end %>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
require "rails_helper"

RSpec.feature "Early years payment provider" do
let(:email_address) { "[email protected]" }
let(:journey_session) { Journeys::EarlyYearsPayment::Provider::Authenticated::Session.last }
let(:mail) { ActionMailer::Base.deliveries.last }
let(:magic_link) { mail[:personalisation].unparsed_value[:magic_link] }
let!(:nursery) { create(:eligible_ey_provider, primary_key_contact_email_address: email_address) }

scenario "preventing the user from bypassing employee email" do
when_early_years_payment_provider_authenticated_journey_configuration_exists
when_early_years_payment_provider_start_journey_completed

visit magic_link
expect(journey_session.reload.answers.email_address).to eq email_address
expect(journey_session.reload.answers.email_verified).to be true
expect(page).to have_content("Declaration of Employee Consent")
expect(page.current_path).to eq "/early-years-payment-provider/consent"
check "I confirm that I have obtained consent from my employee and have provided them with the relevant privacy notice."
click_button "Continue"

expect(page.current_path).to eq "/early-years-payment-provider/current-nursery"
choose nursery.nursery_name
click_button "Continue"

expect(page.current_path).to eq "/early-years-payment-provider/paye-reference"
expect(page).to have_content("What is #{nursery.nursery_name}’s employer PAYE reference?")
fill_in "claim-paye-reference-field", with: "123/123456SE90"
click_button "Continue"

expect(page.current_path).to eq "/early-years-payment-provider/claimant-name"
fill_in "First name", with: "Bobby"
fill_in "Last name", with: "Bobberson"
click_button "Continue"

expect(page.current_path).to eq "/early-years-payment-provider/start-date"
date = Date.yesterday
fill_in("Day", with: date.day)
fill_in("Month", with: date.month)
fill_in("Year", with: date.year)
click_button "Continue"

expect(page.current_path).to eq "/early-years-payment-provider/child-facing"
choose "Yes"
click_button "Continue"

expect(page.current_path).to eq "/early-years-payment-provider/returner"
choose "Yes"
click_button "Continue"

expect(page.current_path).to eq "/early-years-payment-provider/returner-worked-with-children"
choose "Yes"
click_button "Continue"

expect(page.current_path).to eq "/early-years-payment-provider/returner-contract-type"
choose "casual or temporary"
click_button "Continue"

expect(page.current_path).to eq "/early-years-payment-provider/employee-email"
click_button "Continue"
expect(page).to have_content("Error: Enter a valid email address")

click_link "Back"
expect(page.current_path).to eq "/early-years-payment-provider/returner-contract-type"
choose "voluntary or unpaid"
click_button "Continue"

expect(page.current_path).to eq "/early-years-payment-provider/employee-email"
fill_in "claim-practitioner-email-address-field", with: "[email protected]"
click_button "Continue"

expect(page.current_path).to eq "/early-years-payment-provider/check-your-answers"
expect(page).to have_content("Check your answers before submitting this claim")
end
end
120 changes: 36 additions & 84 deletions spec/models/journeys/additional_payments_for_teaching_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,112 +67,64 @@
it { is_expected.to eq(Journeys::AdditionalPaymentsForTeaching::AnswersPresenter) }
end

describe ".set_a_reminder?" do
subject { described_class.set_a_reminder?(itt_academic_year: itt_academic_year, policy_year: policy_year) }
let(:itt_academic_year) { AcademicYear.new(year) }

context "Claim year: 22/23" do
let(:policy_year) { AcademicYear.new(2022) }

# Eligible now - but falls out of 5 year window next year so don't set a reminder
context "ITT year: 17/18" do
let(:year) { 2017 }
shared_examples "true for years" do |start_years_range, policy_year|
JourneySubjectEligibilityChecker.selectable_itt_years_for_claim_year(policy_year).each do |itt_academic_year|
context "ITT year #{itt_academic_year}" do
let(:itt_academic_year) { itt_academic_year }

specify { expect(subject).to be false }
end

context "ITT year: 18/19" do
let(:year) { 2018 }

specify { expect(subject).to be true }
if start_years_range.include?(itt_academic_year.start_year)
it { is_expected.to be true }
else
it { is_expected.to be false }
end
end
end
end

context "ITT year: 19/20" do
let(:year) { 2019 }
shared_examples "false for all years" do |policy_year|
JourneySubjectEligibilityChecker.selectable_itt_years_for_claim_year(policy_year).each do |itt_academic_year|
context "ITT year #{itt_academic_year}" do
let(:itt_academic_year) { itt_academic_year }

specify { expect(subject).to be true }
it { is_expected.to be false }
end
end
end

context "ITT year: 20/21" do
let(:year) { 2020 }

specify { expect(subject).to be true }
end
describe ".set_a_reminder?" do
subject { described_class.set_a_reminder?(itt_academic_year: itt_academic_year, policy: policy) }
let(:policy) { Policies::EarlyCareerPayments }
let!(:configuration) { create(:journey_configuration, :additional_payments, current_academic_year: policy_year) }

context "ITT year: 21/22" do
let(:year) { 2021 }
context "Claim year: 22/23" do
let(:policy_year) { AcademicYear.new(2022) }

specify { expect(subject).to be true }
end
# 2017 is eligible now - but falls out of the 5 year window next year
it_behaves_like "true for years", 2018..2021, AcademicYear.new(2022)
end

context "Claim year: 23/24" do
let(:policy_year) { AcademicYear.new(2023) }

# Eligible now - but falls out of 5 year window next year so don't set a reminder
context "ITT year: 18/19" do
let(:year) { 2018 }

specify { expect(subject).to be false }
end

context "ITT year: 19/20" do
let(:year) { 2019 }

specify { expect(subject).to be true }
end

context "ITT year: 20/21" do
let(:year) { 2020 }

specify { expect(subject).to be true }
end

context "ITT year: 21/22" do
let(:year) { 2021 }

specify { expect(subject).to be true }
end

context "ITT year: 22/23" do
let(:year) { 2022 }

specify { expect(subject).to be true }
end
# 2018 is eligible now - but falls out of the 5 year window next year
it_behaves_like "true for years", 2019..2022, AcademicYear.new(2023)
end

# Last policy year - no reminders to set
context "Claim year: 24/25" do
let(:policy_year) { AcademicYear.new(2024) }

context "ITT year: 19/20" do
let(:year) { 2019 }

specify { expect(subject).to be false }
end

context "ITT year: 20/21" do
let(:year) { 2020 }

specify { expect(subject).to be false }
end

context "ITT year: 21/22" do
let(:year) { 2021 }

specify { expect(subject).to be false }
end

context "ITT year: 22/23" do
let(:year) { 2022 }
context "Last year of the policy - ECP policy" do
let(:policy) { Policies::EarlyCareerPayments }

specify { expect(subject).to be false }
# ECP will be removed after 2024/2025 academic year
it_behaves_like "false for all years", AcademicYear.new(2024)
end

context "ITT year: 23/24" do
let(:year) { 2023 }
context "LUP policy" do
let(:policy) { Policies::LevellingUpPremiumPayments }

specify { expect(subject).to be false }
# 2019 is eligible now - but falls out of the 5 year window next year
it_behaves_like "true for years", 2020..2023, AcademicYear.new(2024)
end
end
end
Expand Down

0 comments on commit fc8657d

Please sign in to comment.