Skip to content

Commit

Permalink
Remove AP specifc logic from page sequence
Browse files Browse the repository at this point in the history
Previously the page sequence contained specific logic for handling an
additional payments sub journey (traniee teacher), and rather than
modifying the slug sequence just overwrote what is returned.
Additionally there was a condition in the slug sequence that caused the
whole thing to be swapped out if we were dealing with a trainee teacher.
This commit removes the additional payments specific handling from the
page sequence, leaving it journey agnostic, and updates the additional
payments slug sequence to move the trainee teacher sub journey branching
to the top level.
  • Loading branch information
rjlynch committed Nov 20, 2024
1 parent 5146720 commit 47236ce
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ class SlugSequence
RESULTS_SLUGS
).freeze

TRAINEE_TEACHER_SLUGS = %w[
current-school
nqt-in-academic-year-after-itt
eligible-itt-subject
eligible-degree-subject
future-eligibility
ineligible
]

attr_reader :journey_session

delegate :answers, to: :journey_session
Expand All @@ -81,9 +90,15 @@ def initialize(journey_session)
@journey_session = journey_session
end

# Even though we are inside the ECP namespace, this method can modify the
# slug sequence of both LUP and ECP claims
def slugs
if answers.trainee_teacher? && Policies::LevellingUpPremiumPayments::SchoolEligibility.new(answers.current_school).eligible?
lup_trainee_journey_slugs
else
non_trainee_journey_slugs
end
end

def non_trainee_journey_slugs
SLUGS.dup.tap do |sequence|
if !Journeys::AdditionalPaymentsForTeaching.configuration.teacher_id_enabled?
sequence.delete("sign-in-or-continue")
Expand Down Expand Up @@ -132,14 +147,9 @@ def slugs
sequence.delete("mobile-verification")
end

if answers.trainee_teacher?
trainee_teacher_slugs!(sequence)
sequence.delete("eligible-degree-subject") unless lup_eligibility_checker.indicated_ineligible_itt_subject?
else
sequence.delete("ineligible") unless [:ineligible, :eligible_later].include?(overall_eligibility_status)
sequence.delete("future-eligibility")
sequence.delete("eligible-degree-subject") unless ecp_eligibility_checker.status == :ineligible && lup_eligibility_checker.indicated_ineligible_itt_subject?
end
sequence.delete("ineligible") unless [:ineligible, :eligible_later].include?(overall_eligibility_status)
sequence.delete("future-eligibility")
sequence.delete("eligible-degree-subject") unless ecp_eligibility_checker.status == :ineligible && lup_eligibility_checker.indicated_ineligible_itt_subject?

sequence.delete("induction-completed") unless induction_question_required?

Expand All @@ -164,6 +174,14 @@ def slugs
end
end

def lup_trainee_journey_slugs
TRAINEE_TEACHER_SLUGS.dup.tap do |sequence|
if lup_eligibility_checker.status == :eligible_later && answers.eligible_degree_subject.nil?
sequence.delete("eligible-degree-subject")
end
end
end

def self.start_page_url
Rails.application.routes.url_helpers.landing_page_path("additional-payments")
end
Expand All @@ -190,21 +208,6 @@ def replace_ecp_only_induction_not_completed_slugs(sequence)
sequence.replace(slugs)
end

# This method swaps out the entire slug sequence and replaces it with this tiny
# journey.
def trainee_teacher_slugs!(sequence)
trainee_slugs = %w[
current-school
nqt-in-academic-year-after-itt
eligible-itt-subject
eligible-degree-subject
future-eligibility
ineligible
]

[sequence.dup - trainee_slugs].flatten.each { |slug| sequence.delete(slug) }
end

def induction_question_required?
# Induction question is not required if an ECP-eligible school is not selected.
return false unless ecp_school_selected?
Expand Down
27 changes: 0 additions & 27 deletions app/models/journeys/page_sequence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ def slugs
def next_slug
return "ineligible" if journey_ineligible?

if lup_policy_and_trainee_teacher_at_lup_school?
return handle_trainee_teacher
end

if claim_submittable?
return "student-loan-amount" if updating_personal_details? && in_sequence?("student-loan-amount")
return "check-your-answers"
Expand Down Expand Up @@ -87,29 +83,6 @@ def can_skip_next_slug?
true if current_slug == "select-home-address" && answers.postcode.present?
end

def lup_policy_and_trainee_teacher_at_lup_school?
journey == Journeys::AdditionalPaymentsForTeaching && lup_trainee_at_lup_school
end

def lup_trainee_at_lup_school
answers.nqt_in_academic_year_after_itt == false && Policies::LevellingUpPremiumPayments::SchoolEligibility.new(answers.current_school).eligible?
end

def handle_trainee_teacher
case current_slug
when "nqt-in-academic-year-after-itt"
"eligible-itt-subject"
when "eligible-itt-subject"
if answers.eligible_itt_subject.to_sym.in? Policies::LevellingUpPremiumPayments.fixed_subject_symbols
"future-eligibility"
else
"eligible-degree-subject"
end
when "eligible-degree-subject"
"future-eligibility"
end
end

def current_slug_index
slugs.index(current_slug) || 0
end
Expand Down

0 comments on commit 47236ce

Please sign in to comment.