From d267f6bee9254e7d9fa38baf46e80ba67932fe6f Mon Sep 17 00:00:00 2001 From: Richard Lynch Date: Tue, 19 Nov 2024 16:40:24 +0000 Subject: [PATCH] Move fixed_subject_symbols Move fixed_lup_subject_symbols of off JourneySubjectEligibilityChecker and onto LevellingUpPremiumPayments policy as this method is policy specific. --- app/helpers/claims/itt_subject_helper.rb | 2 +- .../policies/levelling_up_premium_payments.rb | 3 + .../policy_eligibility_checker.rb | 2 +- .../claims/eligible_degree_subject.html.erb | 2 +- lib/journey_subject_eligibility_checker.rb | 30 --- .../early_career_payments_helper_spec.rb | 2 +- ...ourney_subject_eligibility_checker_spec.rb | 200 ------------------ .../dqt_record_spec.rb | 2 +- 8 files changed, 8 insertions(+), 235 deletions(-) diff --git a/app/helpers/claims/itt_subject_helper.rb b/app/helpers/claims/itt_subject_helper.rb index 5cd55a0fda..79e057a780 100644 --- a/app/helpers/claims/itt_subject_helper.rb +++ b/app/helpers/claims/itt_subject_helper.rb @@ -4,7 +4,7 @@ module Claims module IttSubjectHelper def subjects_to_sentence_for_hint_text(answers) all_ecp_subjects = [:chemistry, :foreign_languages, :mathematics, :physics] - all_lup_subjects = JourneySubjectEligibilityChecker.fixed_lup_subject_symbols + all_lup_subjects = Policies::LevellingUpPremiumPayments.fixed_subject_symbols hint_subject_symbols = Set[] diff --git a/app/models/policies/levelling_up_premium_payments.rb b/app/models/policies/levelling_up_premium_payments.rb index 62b7cc5e36..d7cec6ec7d 100644 --- a/app/models/policies/levelling_up_premium_payments.rb +++ b/app/models/policies/levelling_up_premium_payments.rb @@ -123,6 +123,9 @@ def current_and_future_subject_symbols(claim_year:, itt_year:) ].uniq end + # Ideally we wouldn't have this method at all. Unfortunately it was hardcoded like + # this before we realised trainee teachers weren't as special a case as we + # thought. def fixed_subject_symbols [:chemistry, :computing, :mathematics, :physics] end diff --git a/app/models/policies/levelling_up_premium_payments/policy_eligibility_checker.rb b/app/models/policies/levelling_up_premium_payments/policy_eligibility_checker.rb index 3a0285a1cb..c3d86f1c6d 100644 --- a/app/models/policies/levelling_up_premium_payments/policy_eligibility_checker.rb +++ b/app/models/policies/levelling_up_premium_payments/policy_eligibility_checker.rb @@ -62,7 +62,7 @@ def good_itt_subject? if args.values.any?(&:blank?) # trainee teacher who won't have given their ITT year - eligible_itt_subject.present? && eligible_itt_subject.to_sym.in?(JourneySubjectEligibilityChecker.fixed_lup_subject_symbols) + eligible_itt_subject.present? && eligible_itt_subject.to_sym.in?(Policies::LevellingUpPremiumPayments.fixed_subject_symbols) else itt_subject_checker = JourneySubjectEligibilityChecker.new(**args) eligible_itt_subject.to_sym.in?(itt_subject_checker.current_subject_symbols(policy)) diff --git a/app/views/additional_payments/claims/eligible_degree_subject.html.erb b/app/views/additional_payments/claims/eligible_degree_subject.html.erb index bae29a44c3..1a292e2ff3 100644 --- a/app/views/additional_payments/claims/eligible_degree_subject.html.erb +++ b/app/views/additional_payments/claims/eligible_degree_subject.html.erb @@ -18,7 +18,7 @@
This can be an undergraduate or postgraduate degree in - <%= JourneySubjectEligibilityChecker.fixed_lup_subject_symbols.to_sentence(last_word_connector: ' or ') %>. + <%= Policies::LevellingUpPremiumPayments.fixed_subject_symbols.to_sentence(last_word_connector: ' or ') %>.
<%= errors_tag f.object, :eligible_degree_subject %> diff --git a/lib/journey_subject_eligibility_checker.rb b/lib/journey_subject_eligibility_checker.rb index e7f58cda81..a1048c9c87 100644 --- a/lib/journey_subject_eligibility_checker.rb +++ b/lib/journey_subject_eligibility_checker.rb @@ -18,28 +18,6 @@ def future_claim_years end end - def self.selectable_subject_symbols(answers) - if answers.nqt_in_academic_year_after_itt - new( - claim_year: answers.policy_year, - itt_year: answers.itt_academic_year - ).selectable_subject_symbols(answers) - elsif answers.policy_year.in?(EligibilityCheckable::COMBINED_ECP_AND_LUP_POLICY_YEARS_BEFORE_FINAL_YEAR) - # they get the standard, unchanging LUP subject set because they won't have qualified in time for ECP by 2022/2023 - # and they won't have given an ITT year - fixed_lup_subject_symbols - else - [] - end.sort - end - - # Ideally we wouldn't have this method at all. Unfortunately it was hardcoded like - # this before we realised trainee teachers weren't as special a case as we - # thought. - def self.fixed_lup_subject_symbols - [:chemistry, :computing, :mathematics, :physics] - end - # FIXME RL - should be able to delete all the methods using this def current_and_future_subject_symbols(policy) (current_subject_symbols(policy) + future_subject_symbols(policy)).uniq @@ -65,14 +43,6 @@ def future_subject_symbols(policy) end end - def selectable_subject_symbols(answers) - return [] if answers.itt_academic_year.blank? - - potentially_still_eligible_policies(answers).map do |policy| - current_and_future_subject_symbols(policy) - end.flatten.uniq - end - private # Move this diff --git a/spec/helpers/early_career_payments_helper_spec.rb b/spec/helpers/early_career_payments_helper_spec.rb index df975b10eb..7a02816854 100644 --- a/spec/helpers/early_career_payments_helper_spec.rb +++ b/spec/helpers/early_career_payments_helper_spec.rb @@ -29,7 +29,7 @@ subject do helper.eligible_itt_subject_translation( journey_session.answers, - JourneySubjectEligibilityChecker.selectable_subject_symbols(journey_session.answers) + Journeys::AdditionalPaymentsForTeaching.selectable_subject_symbols(journey_session) ) end diff --git a/spec/lib/journey_subject_eligibility_checker_spec.rb b/spec/lib/journey_subject_eligibility_checker_spec.rb index f8133d7862..c4daf1fb00 100644 --- a/spec/lib/journey_subject_eligibility_checker_spec.rb +++ b/spec/lib/journey_subject_eligibility_checker_spec.rb @@ -518,204 +518,4 @@ end end end - - describe "#selectable_subject_symbols" do - subject do - described_class.new( - claim_year: claim_year, itt_year: itt_year - ).selectable_subject_symbols(journey_session.answers) - end - - context "when academic year is 2022" do - before { create(:journey_configuration, :additional_payments, current_academic_year: AcademicYear.new(2022)) } - - context "2022 claim year" do - let(:claim_year) { AcademicYear.new(2022) } - - context "None of the above ITT year" do - let(:itt_year) { AcademicYear.new } - - let(:journey_session) do - create(:additional_payments_session) - end - - it { is_expected.to be_empty } - end - - context "2017 ITT year" do - let(:itt_year) { AcademicYear.new(2017) } - - context "ineligible LUP" do - let(:journey_session) do - create( - :additional_payments_session, - answers: attributes_for( - :additional_payments_answers, - :ecp_eligible, - itt_academic_year: itt_year - ) - ) - end - - it { is_expected.to be_empty } - end - - context "eligible LUP" do - let(:journey_session) do - create( - :additional_payments_session, - answers: attributes_for( - :additional_payments_answers, - :ecp_and_lup_eligible, - itt_academic_year: itt_year - ) - ) - end - - it { is_expected.to contain_exactly(:chemistry, :computing, :mathematics, :physics) } - end - end - - context "2018 ITT year" do - let(:itt_year) { AcademicYear.new(2018) } - - context "ineligible LUP" do - let(:journey_session) do - create( - :additional_payments_session, - answers: attributes_for( - :additional_payments_answers, - :ecp_eligible, - itt_academic_year: itt_year - ) - ) - end - - it { is_expected.to contain_exactly(:mathematics) } - end - - context "eligible LUP" do - let(:journey_session) do - create( - :additional_payments_session, - answers: attributes_for( - :additional_payments_answers, - :ecp_and_lup_eligible, - itt_academic_year: itt_year - ) - ) - end - - it { is_expected.to contain_exactly(:chemistry, :computing, :mathematics, :physics) } - end - end - - context "2019 ITT year" do - let(:itt_year) { AcademicYear.new(2019) } - - context "ineligible LUP" do - let(:journey_session) do - create( - :additional_payments_session, - answers: attributes_for( - :additional_payments_answers, - :ecp_eligible, - itt_academic_year: itt_year - ) - ) - end - - it { is_expected.to contain_exactly(:mathematics) } - end - - context "eligible LUP" do - let(:journey_session) do - create( - :additional_payments_session, - answers: attributes_for( - :additional_payments_answers, - :ecp_and_lup_eligible, - itt_academic_year: itt_year - ) - ) - end - - it { is_expected.to contain_exactly(:chemistry, :computing, :mathematics, :physics) } - end - end - - context "2020 ITT year" do - let(:itt_year) { AcademicYear.new(2020) } - - context "ineligible LUP" do - let(:journey_session) do - create( - :additional_payments_session, - answers: attributes_for( - :additional_payments_answers, - :ecp_eligible, - itt_academic_year: itt_year - ) - ) - end - - it { is_expected.to contain_exactly(:chemistry, :foreign_languages, :mathematics, :physics) } - end - - context "eligible LUP" do - let(:journey_session) do - create( - :additional_payments_session, - answers: attributes_for( - :additional_payments_answers, - :ecp_and_lup_eligible, - itt_academic_year: itt_year - ) - ) - end - - it { is_expected.to contain_exactly(:chemistry, :computing, :foreign_languages, :mathematics, :physics) } - end - end - - context "2021 ITT year" do - let(:itt_year) { AcademicYear.new(2021) } - - context "ineligible LUP" do - let(:journey_session) do - create( - :additional_payments_session, - answers: attributes_for( - :additional_payments_answers, - :ecp_eligible, - itt_academic_year: itt_year - ) - ) - end - - it { is_expected.to be_empty } - end - - context "eligible LUP" do - let(:journey_session) do - create( - :additional_payments_session, - answers: attributes_for( - :additional_payments_answers, - :ecp_and_lup_eligible, - itt_academic_year: itt_year - ) - ) - end - - it { is_expected.to contain_exactly(:chemistry, :computing, :mathematics, :physics) } - end - end - end - end - end - - describe ".fixed_lup_subject_symbols" do - specify { expect(described_class.fixed_lup_subject_symbols).to contain_exactly(:chemistry, :computing, :mathematics, :physics) } - end end diff --git a/spec/models/policies/levelling_up_premium_payments/dqt_record_spec.rb b/spec/models/policies/levelling_up_premium_payments/dqt_record_spec.rb index 4138fc5cd0..e84cccaaa9 100644 --- a/spec/models/policies/levelling_up_premium_payments/dqt_record_spec.rb +++ b/spec/models/policies/levelling_up_premium_payments/dqt_record_spec.rb @@ -289,7 +289,7 @@ let(:eligible_subjects) { [:computing] } before do - allow(JourneySubjectEligibilityChecker).to receive(:fixed_lup_subject_symbols) + allow(Policies::LevellingUpPremiumPayments).to receive(:fixed_subject_symbols) .and_return(eligible_subjects) end