From 6cd397fe24daea989b40812465e9f6e2c6e1c095 Mon Sep 17 00:00:00 2001 From: Richard Lynch Date: Fri, 8 Nov 2024 16:58:09 +0000 Subject: [PATCH] Move journey_requires_student_loan_details method This method is a concern of the journey, not the claim callbacks. --- app/controllers/claims_form_callbacks.rb | 28 ++----------------- .../additional_payments_for_teaching.rb | 4 +++ app/models/journeys/base.rb | 4 +++ .../early_years_payment/practitioner.rb | 4 +++ .../journeys/further_education_payments.rb | 4 +++ .../get_a_teacher_relocation_payment.rb | 4 +++ .../teacher_student_loan_reimbursement.rb | 4 +++ 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/app/controllers/claims_form_callbacks.rb b/app/controllers/claims_form_callbacks.rb index 36bf4a7e0f..f7c71f242f 100644 --- a/app/controllers/claims_form_callbacks.rb +++ b/app/controllers/claims_form_callbacks.rb @@ -28,13 +28,13 @@ def personal_bank_account_before_update end def information_provided_before_update - return unless journey_requires_student_loan_details? + return unless journey.requires_student_loan_details? retrieve_student_loan_details if on_tid_route? end def personal_details_after_form_save_success - return redirect_to_next_slug unless journey_requires_student_loan_details? + return redirect_to_next_slug unless journey.requires_student_loan_details? retrieve_student_loan_details redirect_to_next_slug @@ -119,28 +119,4 @@ def current_hmrc_validation_attempt_count def on_tid_route? journey_session.answers.logged_in_with_tid? && journey_session.answers.all_personal_details_same_as_tid? end - - def journey_requires_student_loan_details? - 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? - current_journey_routing_name == "student-loans" - end - - def additional_payments_journey? - current_journey_routing_name == "additional-payments" - end - - def get_a_teacher_relocation_payment_journey? - current_journey_routing_name == "get-a-teacher-relocation-payment" - end - - 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 diff --git a/app/models/journeys/additional_payments_for_teaching.rb b/app/models/journeys/additional_payments_for_teaching.rb index 92fa5619b8..14cbaa4a3f 100644 --- a/app/models/journeys/additional_payments_for_teaching.rb +++ b/app/models/journeys/additional_payments_for_teaching.rb @@ -49,5 +49,9 @@ def set_a_reminder?(itt_academic_year:, policy:) eligible_itt_years = JourneySubjectEligibilityChecker.selectable_itt_years_for_claim_year(next_year) eligible_itt_years.include?(itt_academic_year) end + + def requires_student_loan_details? + true + end end end diff --git a/app/models/journeys/base.rb b/app/models/journeys/base.rb index b9c2ed9def..4cb1844717 100644 --- a/app/models/journeys/base.rb +++ b/app/models/journeys/base.rb @@ -65,5 +65,9 @@ def answers_for_claim(journey_session) def start_with_magic_link? defined?(self::START_WITH_MAGIC_LINK) && self::START_WITH_MAGIC_LINK end + + def requires_student_loan_details? + false + end end end diff --git a/app/models/journeys/early_years_payment/practitioner.rb b/app/models/journeys/early_years_payment/practitioner.rb index 12323a0564..d2515b985c 100644 --- a/app/models/journeys/early_years_payment/practitioner.rb +++ b/app/models/journeys/early_years_payment/practitioner.rb @@ -14,6 +14,10 @@ module Practitioner "enter-home-address" => AddressForm } } + + def requires_student_loan_details? + true + end end end end diff --git a/app/models/journeys/further_education_payments.rb b/app/models/journeys/further_education_payments.rb index a67c6562a1..6117b0787f 100644 --- a/app/models/journeys/further_education_payments.rb +++ b/app/models/journeys/further_education_payments.rb @@ -36,5 +36,9 @@ module FurtherEducationPayments "teacher-reference-number" => TeacherReferenceNumberForm } } + + def requires_student_loan_details? + true + end end end diff --git a/app/models/journeys/get_a_teacher_relocation_payment.rb b/app/models/journeys/get_a_teacher_relocation_payment.rb index 7e1ceb5c02..865619ccd3 100644 --- a/app/models/journeys/get_a_teacher_relocation_payment.rb +++ b/app/models/journeys/get_a_teacher_relocation_payment.rb @@ -22,5 +22,9 @@ module GetATeacherRelocationPayment "personal-details" => PersonalDetailsForm } } + + def requires_student_loan_details? + true + end end end diff --git a/app/models/journeys/teacher_student_loan_reimbursement.rb b/app/models/journeys/teacher_student_loan_reimbursement.rb index f7b21ba3d3..ab02d66cb0 100644 --- a/app/models/journeys/teacher_student_loan_reimbursement.rb +++ b/app/models/journeys/teacher_student_loan_reimbursement.rb @@ -24,5 +24,9 @@ module TeacherStudentLoanReimbursement "select-home-address" => SelectHomeAddressForm } }.freeze + + def requires_student_loan_details? + true + end end end