Skip to content

Commit

Permalink
Move fixed_subject_symbols
Browse files Browse the repository at this point in the history
Move fixed_lup_subject_symbols of off JourneySubjectEligibilityChecker
and onto LevellingUpPremiumPayments policy as this method is policy
specific.
  • Loading branch information
rjlynch committed Dec 11, 2024
1 parent f46a866 commit d267f6b
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 235 deletions.
2 changes: 1 addition & 1 deletion app/helpers/claims/itt_subject_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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[]

Expand Down
3 changes: 3 additions & 0 deletions app/models/policies/levelling_up_premium_payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<div class="govuk-hint" id="has_uk_maths_or_physics_degree-hint">
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 ') %>.
</div>

<%= errors_tag f.object, :eligible_degree_subject %>
Expand Down
30 changes: 0 additions & 30 deletions lib/journey_subject_eligibility_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/helpers/early_career_payments_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
200 changes: 0 additions & 200 deletions spec/lib/journey_subject_eligibility_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d267f6b

Please sign in to comment.