diff --git a/app/controllers/claims_controller.rb b/app/controllers/claims_controller.rb index 3a46f9ea97..01729f74f7 100644 --- a/app/controllers/claims_controller.rb +++ b/app/controllers/claims_controller.rb @@ -31,7 +31,7 @@ def show end # TODO: Migrate the remaining slugs to form objects. - if @form ||= journey.form(claim: current_claim, params:) + if @form ||= journey.form(claim: current_claim, journey_session:, params:) set_any_backlink_override render current_template return @@ -63,7 +63,7 @@ def update params[:claim][:hmrc_validation_attempt_count] = session[:hmrc_validation_attempt_count] || 0 if on_banking_page? # TODO: Migrate the remaining slugs to form objects. - if (@form = journey.form(claim: current_claim, params:)) + if (@form = journey.form(claim: current_claim, journey_session:, params:)) if @form.save retrieve_student_loan_details update_session_with_selected_policy @@ -120,7 +120,12 @@ def next_slug def redirect_to_existing_claim_journey new_journey = Journeys.for_policy(current_claim.policy) - new_page_sequence = new_journey.page_sequence_for_claim(current_claim, session[:slugs], params[:slug]) + new_page_sequence = new_journey.page_sequence_for_claim( + current_claim, + journey_session, + session[:slugs], + params[:slug] + ) redirect_to(claim_path(new_journey::ROUTING_NAME, slug: new_page_sequence.next_required_slug)) end @@ -197,7 +202,12 @@ def claim_in_progress? end def page_sequence - @page_sequence ||= journey.page_sequence_for_claim(current_claim, session[:slugs], params[:slug]) + @page_sequence ||= journey.page_sequence_for_claim( + current_claim, + journey_session, + session[:slugs], + params[:slug] + ) end def prepend_view_path_for_journey diff --git a/app/forms/claim_school_form.rb b/app/forms/claim_school_form.rb index 1aad6af32d..c9592ac5bc 100644 --- a/app/forms/claim_school_form.rb +++ b/app/forms/claim_school_form.rb @@ -6,7 +6,7 @@ class ClaimSchoolForm < Form validates :claim_school_id, presence: {message: i18n_error_message(:select_a_school)} validate :claim_school_must_exist, if: -> { claim_school_id.present? } - def initialize(claim:, journey:, params:) + def initialize(claim:, journey_session:, journey:, params:) super load_schools diff --git a/app/forms/current_school_form.rb b/app/forms/current_school_form.rb index 54e7ea4902..dcdc6aa15e 100644 --- a/app/forms/current_school_form.rb +++ b/app/forms/current_school_form.rb @@ -6,7 +6,7 @@ class CurrentSchoolForm < Form validates :current_school_id, presence: {message: i18n_error_message(:select_the_school_you_teach_at)} validate :current_school_must_be_open, if: -> { current_school_id.present? } - def initialize(claim:, journey:, params:) + def initialize(claim:, journey_session:, journey:, params:) super load_schools diff --git a/app/forms/form.rb b/app/forms/form.rb index 5ca61d304e..c2a6cc0e4e 100644 --- a/app/forms/form.rb +++ b/app/forms/form.rb @@ -6,6 +6,7 @@ class Form attr_accessor :claim attr_accessor :journey + attr_accessor :journey_session attr_accessor :params delegate :persisted?, to: :claim @@ -18,7 +19,8 @@ def self.i18n_error_message(path) ->(object, _) { object.i18n_errors_path(path) } end - def initialize(claim:, journey:, params:) + # TODO RL: remove journey param and pull it from the journey_session + def initialize(claim:, journey_session:, journey:, params:) super assign_attributes(attributes_with_current_value) @@ -67,7 +69,7 @@ def i18n_form_namespace def page_sequence @page_sequence ||= Journeys::PageSequence.new( claim, - journey.slug_sequence.new(claim), + journey.slug_sequence.new(claim, journey_session), nil, params[:slug] ) diff --git a/app/forms/journeys/additional_payments_for_teaching/nqt_in_academic_year_after_itt_form.rb b/app/forms/journeys/additional_payments_for_teaching/nqt_in_academic_year_after_itt_form.rb index 58c2dda830..fc9ac514ef 100644 --- a/app/forms/journeys/additional_payments_for_teaching/nqt_in_academic_year_after_itt_form.rb +++ b/app/forms/journeys/additional_payments_for_teaching/nqt_in_academic_year_after_itt_form.rb @@ -58,6 +58,7 @@ def passed_details_check_with_teacher_id? def set_qualification! QualificationForm.new( journey: journey, + journey_session: journey_session, claim: claim, params: ActionController::Parameters.new( claim: { diff --git a/app/forms/personal_details_form.rb b/app/forms/personal_details_form.rb index 3be6592c76..8a0ccba180 100644 --- a/app/forms/personal_details_form.rb +++ b/app/forms/personal_details_form.rb @@ -40,7 +40,7 @@ def future? validates :national_insurance_number, presence: {message: "Enter a National Insurance number in the correct format"} validate :ni_number_is_correct_format - def initialize(claim:, journey:, params:) + def initialize(claim:, journey_session:, journey:, params:) super assign_date_attributes end diff --git a/app/models/journeys/additional_payments_for_teaching/slug_sequence.rb b/app/models/journeys/additional_payments_for_teaching/slug_sequence.rb index b2bffd2517..4fed88fe14 100644 --- a/app/models/journeys/additional_payments_for_teaching/slug_sequence.rb +++ b/app/models/journeys/additional_payments_for_teaching/slug_sequence.rb @@ -75,11 +75,12 @@ class SlugSequence RESULTS_SLUGS ).freeze - attr_reader :claim + attr_reader :claim, :journey_session # Really this is a combined CurrentClaim - def initialize(claim) + def initialize(claim, journey_session) @claim = claim + @journey_session = journey_session end # Even though we are inside the ECP namespace, this method can modify the @@ -179,6 +180,7 @@ def self.start_page_url def personal_details_form PersonalDetailsForm.new( claim:, + journey_session:, journey: Journeys::AdditionalPaymentsForTeaching, params: ActionController::Parameters.new ) diff --git a/app/models/journeys/base.rb b/app/models/journeys/base.rb index 5633c5ab90..c7b4fc6103 100644 --- a/app/models/journeys/base.rb +++ b/app/models/journeys/base.rb @@ -31,18 +31,23 @@ def slug_sequence self::SlugSequence end - def form(claim:, params:) + def form(claim:, journey_session:, params:) form = SHARED_FORMS.merge(forms)[params[:slug]] - form&.new(journey: self, claim:, params:) + form&.new(journey: self, journey_session:, claim:, params:) end def forms defined?(self::FORMS) ? self::FORMS : {} end - def page_sequence_for_claim(claim, completed_slugs, current_slug) - PageSequence.new(claim, slug_sequence.new(claim), completed_slugs, current_slug) + def page_sequence_for_claim(claim, journey_session, completed_slugs, current_slug) + PageSequence.new( + claim, + slug_sequence.new(claim, journey_session), + completed_slugs, + current_slug + ) end def answers_presenter diff --git a/app/models/journeys/teacher_student_loan_reimbursement/slug_sequence.rb b/app/models/journeys/teacher_student_loan_reimbursement/slug_sequence.rb index 7d15a902b4..031af65c0e 100644 --- a/app/models/journeys/teacher_student_loan_reimbursement/slug_sequence.rb +++ b/app/models/journeys/teacher_student_loan_reimbursement/slug_sequence.rb @@ -61,10 +61,11 @@ class SlugSequence RESULTS_SLUGS ).freeze - attr_reader :claim + attr_reader :claim, :journey_session - def initialize(claim) + def initialize(claim, journey_session) @claim = claim + @journey_session = journey_session end def slugs @@ -132,6 +133,7 @@ def self.start_page_url def personal_details_form PersonalDetailsForm.new( claim:, + journey_session:, journey: Journeys::TeacherStudentLoanReimbursement, params: ActionController::Parameters.new ) diff --git a/spec/forms/address_form_spec.rb b/spec/forms/address_form_spec.rb index f7390c1699..dd445ea5aa 100644 --- a/spec/forms/address_form_spec.rb +++ b/spec/forms/address_form_spec.rb @@ -1,9 +1,12 @@ require "rails_helper" RSpec.describe AddressForm, type: :model do - subject(:form) { described_class.new(claim:, journey:, params:) } + subject(:form) { described_class.new(claim:, journey:, params:, journey_session:) } let(:journey) { Journeys::TeacherStudentLoanReimbursement } + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end let(:claim) { CurrentClaim.new(claims: [build(:claim, policy: Policies::StudentLoans)]) } let(:slug) { "address" } let(:params) { ActionController::Parameters.new({slug:, claim: claim_params}) } diff --git a/spec/forms/bank_details_form_spec.rb b/spec/forms/bank_details_form_spec.rb index 565c2ecb03..834722f7f8 100644 --- a/spec/forms/bank_details_form_spec.rb +++ b/spec/forms/bank_details_form_spec.rb @@ -12,12 +12,23 @@ CurrentClaim.new(claims: claims) end + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end + let(:slug) { "personal-bank-account" } let(:params) do {banking_name:, bank_sort_code:, bank_account_number:, building_society_roll_number:, hmrc_validation_attempt_count:} end - subject(:form) { described_class.new(claim: current_claim, journey: journey, params: ActionController::Parameters.new(slug:, claim: params)) } + subject(:form) do + described_class.new( + claim: current_claim, + journey_session: journey_session, + journey: journey, + params: ActionController::Parameters.new(slug:, claim: params) + ) + end let(:banking_name) { "Jo Bloggs" } let(:bank_sort_code) { rand(100000..999999) } diff --git a/spec/forms/bank_or_building_society_form_spec.rb b/spec/forms/bank_or_building_society_form_spec.rb index c161657403..2d843fe405 100644 --- a/spec/forms/bank_or_building_society_form_spec.rb +++ b/spec/forms/bank_or_building_society_form_spec.rb @@ -12,10 +12,21 @@ CurrentClaim.new(claims:) end + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end + let(:slug) { "bank-or-building-society-form" } let(:claim_params) { {} } - subject(:form) { described_class.new(claim: current_claim, journey: journey, params: ActionController::Parameters.new({slug:, claim: claim_params})) } + subject(:form) do + described_class.new( + claim: current_claim, + journey_session: journey_session, + journey: journey, + params: ActionController::Parameters.new({slug:, claim: claim_params}) + ) + end describe "validations" do it { should allow_value(%w[personal_bank_account building_society]).for(:bank_or_building_society).with_message("Select if you want the money paid in to a personal bank account or building society") } diff --git a/spec/forms/claim_school_form_spec.rb b/spec/forms/claim_school_form_spec.rb index 2224fc307f..77766274e0 100644 --- a/spec/forms/claim_school_form_spec.rb +++ b/spec/forms/claim_school_form_spec.rb @@ -10,9 +10,20 @@ CurrentClaim.new(claims: claims) end + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end + let(:slug) { "claim-school" } - subject(:form) { described_class.new(claim: current_claim, journey: journey, params: params) } + subject(:form) do + described_class.new( + claim: current_claim, + journey_session: journey_session, + journey: journey, + params: params + ) + end context "unpermitted claim param" do let(:params) { ActionController::Parameters.new({slug: slug, claim: {nonsense_id: 1}}) } diff --git a/spec/forms/current_school_form_spec.rb b/spec/forms/current_school_form_spec.rb index ad544767b6..41744b2016 100644 --- a/spec/forms/current_school_form_spec.rb +++ b/spec/forms/current_school_form_spec.rb @@ -12,9 +12,20 @@ CurrentClaim.new(claims: claims) end + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end + let(:slug) { "current-school" } - subject(:form) { described_class.new(claim: current_claim, journey: journey, params: params) } + subject(:form) do + described_class.new( + claim: current_claim, + journey_session: journey_session, + journey: journey, + params: params + ) + end context "unpermitted claim param" do let(:params) { ActionController::Parameters.new({slug: slug, claim: {nonsense_id: 1}}) } diff --git a/spec/forms/email_address_form_spec.rb b/spec/forms/email_address_form_spec.rb index a9fb8f108b..25155569e8 100644 --- a/spec/forms/email_address_form_spec.rb +++ b/spec/forms/email_address_form_spec.rb @@ -13,6 +13,10 @@ end end + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end + let(:current_claim) { CurrentClaim.new(claims: claims) } let(:params) do @@ -20,7 +24,12 @@ end let(:form) do - described_class.new(journey: journey, claim: current_claim, params: params) + described_class.new( + journey: journey, + journey_session: journey_session, + claim: current_claim, + params: params + ) end describe "validations" do diff --git a/spec/forms/email_verification_form_spec.rb b/spec/forms/email_verification_form_spec.rb index 22d870086e..57de0f4851 100644 --- a/spec/forms/email_verification_form_spec.rb +++ b/spec/forms/email_verification_form_spec.rb @@ -22,8 +22,17 @@ ) end + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end + let(:form) do - described_class.new(journey: journey, claim: current_claim, params: params) + described_class.new( + journey: journey, + journey_session: journey_session, + claim: current_claim, + params: params + ) end around do |example| diff --git a/spec/forms/employed_directly_form_spec.rb b/spec/forms/employed_directly_form_spec.rb index b115ddfd8c..548deccb9f 100644 --- a/spec/forms/employed_directly_form_spec.rb +++ b/spec/forms/employed_directly_form_spec.rb @@ -5,6 +5,10 @@ let(:journey) { Journeys::AdditionalPaymentsForTeaching } + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end + let(:current_claim) do claims = journey::POLICIES.map { |policy| create(:claim, policy:) } CurrentClaim.new(claims:) @@ -12,7 +16,14 @@ let(:slug) { "employed-directly" } - subject(:form) { described_class.new(claim: current_claim, journey:, params:) } + subject(:form) do + described_class.new( + claim: current_claim, + journey_session:, + journey:, + params: + ) + end context "unpermitted claim param" do let(:params) { ActionController::Parameters.new({slug:, claim: {random_param: 1}}) } diff --git a/spec/forms/entire_term_contract_form_spec.rb b/spec/forms/entire_term_contract_form_spec.rb index fc478cc5d7..c69f722ae8 100644 --- a/spec/forms/entire_term_contract_form_spec.rb +++ b/spec/forms/entire_term_contract_form_spec.rb @@ -5,6 +5,10 @@ let(:journey) { Journeys::AdditionalPaymentsForTeaching } + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end + let(:current_claim) do claims = journey::POLICIES.map { |policy| create(:claim, policy:) } CurrentClaim.new(claims:) @@ -12,7 +16,14 @@ let(:slug) { "entire-term-contract" } - subject(:form) { described_class.new(claim: current_claim, journey:, params:) } + subject(:form) do + described_class.new( + claim: current_claim, + journey:, + journey_session:, + params: + ) + end context "unpermitted claim param" do let(:params) { ActionController::Parameters.new({slug:, claim: {random_param: 1}}) } diff --git a/spec/forms/form_spec.rb b/spec/forms/form_spec.rb index 567972262c..9947e872c1 100644 --- a/spec/forms/form_spec.rb +++ b/spec/forms/form_spec.rb @@ -14,7 +14,7 @@ module TestJourney I18N_NAMESPACE = "test_i18n_ns" class SlugSequence - def initialize(claim) + def initialize(claim, journey_session) # NOOP end end @@ -40,11 +40,12 @@ def initialize(claim) end end - subject(:form) { TestSlugForm.new(claim:, journey:, params:) } + subject(:form) { TestSlugForm.new(claim:, journey:, journey_session:, params:) } let(:claim) { CurrentClaim.new(claims:) } let(:claims) { [build(:claim, policy: Policies::StudentLoans)] } let(:journey) { Journeys::TestJourney } + let(:journey_session) { build(:journeys_session) } let(:params) { ActionController::Parameters.new({journey: "test-journey", slug: "test_slug", claim: claim_params}) } let(:claim_params) { {first_name: "test-name"} } diff --git a/spec/forms/gender_form_spec.rb b/spec/forms/gender_form_spec.rb index afda4c9502..d69da0900d 100644 --- a/spec/forms/gender_form_spec.rb +++ b/spec/forms/gender_form_spec.rb @@ -11,9 +11,20 @@ CurrentClaim.new(claims: claims) end + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end + let(:slug) { "gender" } - subject(:form) { described_class.new(claim: current_claim, journey: journey, params: params) } + subject(:form) do + described_class.new( + claim: current_claim, + journey_session: journey_session, + journey: journey, + params: params + ) + end context "unpermitted claim param" do let(:params) { ActionController::Parameters.new({slug: slug, claim: {nonsense_id: 1}}) } diff --git a/spec/forms/journeys/additional_payments_for_teaching/correct_school_form_spec.rb b/spec/forms/journeys/additional_payments_for_teaching/correct_school_form_spec.rb index 5f1ed17299..c1c560af55 100644 --- a/spec/forms/journeys/additional_payments_for_teaching/correct_school_form_spec.rb +++ b/spec/forms/journeys/additional_payments_for_teaching/correct_school_form_spec.rb @@ -14,8 +14,11 @@ let(:claim) { CurrentClaim.new(claims: [create(:claim, policy: Policies::LevellingUpPremiumPayments)]) } let(:journey) { Journeys::AdditionalPaymentsForTeaching } + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end let(:params) { ActionController::Parameters.new } - let(:form) { described_class.new(claim:, journey:, params:) } + let(:form) { described_class.new(claim:, journey:, journey_session:, params:) } let!(:school) { create(:school, :eligible_for_journey, journey:) } context "when choosing a school" do diff --git a/spec/forms/journeys/additional_payments_for_teaching/eligibility_confirmed_form_spec.rb b/spec/forms/journeys/additional_payments_for_teaching/eligibility_confirmed_form_spec.rb index c1bfa48c6e..3bf9b248a8 100644 --- a/spec/forms/journeys/additional_payments_for_teaching/eligibility_confirmed_form_spec.rb +++ b/spec/forms/journeys/additional_payments_for_teaching/eligibility_confirmed_form_spec.rb @@ -1,9 +1,12 @@ require "rails_helper" RSpec.describe Journeys::AdditionalPaymentsForTeaching::EligibilityConfirmedForm, type: :model do - subject(:form) { described_class.new(claim:, journey:, params:) } + subject(:form) { described_class.new(claim:, journey:, journey_session:, params:) } let(:journey) { Journeys::AdditionalPaymentsForTeaching } + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end let(:ecp_claim) { build(:claim, :eligible, policy: Policies::EarlyCareerPayments) } let(:lupp_claim) { build(:claim, :eligible, policy: Policies::LevellingUpPremiumPayments) } let(:claim) { CurrentClaim.new(claims: [ecp_claim, lupp_claim], selected_policy:) } diff --git a/spec/forms/journeys/additional_payments_for_teaching/eligible_degree_subject_form_spec.rb b/spec/forms/journeys/additional_payments_for_teaching/eligible_degree_subject_form_spec.rb index cec779fcbf..afd4b64993 100644 --- a/spec/forms/journeys/additional_payments_for_teaching/eligible_degree_subject_form_spec.rb +++ b/spec/forms/journeys/additional_payments_for_teaching/eligible_degree_subject_form_spec.rb @@ -1,9 +1,14 @@ require "rails_helper" RSpec.describe Journeys::AdditionalPaymentsForTeaching::EligibleDegreeSubjectForm do - subject(:form) { described_class.new(claim:, journey:, params:) } + subject(:form) do + described_class.new(claim:, journey_session:, journey:, params:) + end let(:journey) { Journeys::AdditionalPaymentsForTeaching } + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end let(:ecp_claim) { build(:claim, policy: Policies::EarlyCareerPayments) } let(:lupp_claim) { build(:claim, policy: Policies::LevellingUpPremiumPayments) } let(:claim) { CurrentClaim.new(claims: [ecp_claim, lupp_claim]) } diff --git a/spec/forms/journeys/additional_payments_for_teaching/eligible_itt_subject_form_spec.rb b/spec/forms/journeys/additional_payments_for_teaching/eligible_itt_subject_form_spec.rb index d87a6df8bb..7210ba7633 100644 --- a/spec/forms/journeys/additional_payments_for_teaching/eligible_itt_subject_form_spec.rb +++ b/spec/forms/journeys/additional_payments_for_teaching/eligible_itt_subject_form_spec.rb @@ -9,7 +9,11 @@ ) end - let(:additional_payments_journey) { Journeys::AdditionalPaymentsForTeaching } + let(:journey) { Journeys::AdditionalPaymentsForTeaching } + + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end let(:ecp_trainee_teacher_eligibility) do create( @@ -52,7 +56,8 @@ subject(:form) do described_class.new( - journey: additional_payments_journey, + journey: journey, + journey_session: journey_session, claim: current_claim, params: ActionController::Parameters.new ) @@ -68,7 +73,8 @@ describe "#available_subjects" do let(:form) do described_class.new( - journey: additional_payments_journey, + journey: journey, + journey_session: journey_session, claim: current_claim, params: ActionController::Parameters.new ) @@ -122,7 +128,8 @@ describe "#show_hint_text?" do let(:form) do described_class.new( - journey: additional_payments_journey, + journey: journey, + journey_session: journey_session, claim: current_claim, params: ActionController::Parameters.new ) @@ -163,7 +170,8 @@ describe "#chemistry_or_physics_available?" do let(:form) do described_class.new( - journey: additional_payments_journey, + journey: journey, + journey_session: journey_session, claim: current_claim, params: ActionController::Parameters.new ) @@ -209,7 +217,8 @@ let(:form) do described_class.new( - journey: additional_payments_journey, + journey: journey, + journey_session: journey_session, claim: current_claim, params: params ) diff --git a/spec/forms/journeys/additional_payments_for_teaching/induction_completed_form_spec.rb b/spec/forms/journeys/additional_payments_for_teaching/induction_completed_form_spec.rb index 4e8aba2a44..e1b43bf623 100644 --- a/spec/forms/journeys/additional_payments_for_teaching/induction_completed_form_spec.rb +++ b/spec/forms/journeys/additional_payments_for_teaching/induction_completed_form_spec.rb @@ -13,7 +13,18 @@ let(:slug) { "induction_completed" } - subject(:form) { described_class.new(claim: current_claim, journey: journey, params: params) } + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end + + subject(:form) do + described_class.new( + claim: current_claim, + journey_session: journey_session, + journey: journey, + params: params + ) + end context "unpermitted claim param" do let(:params) { ActionController::Parameters.new({slug: slug, claim: {nonsense_id: 1}}) } diff --git a/spec/forms/journeys/additional_payments_for_teaching/itt_academic_year_form_spec.rb b/spec/forms/journeys/additional_payments_for_teaching/itt_academic_year_form_spec.rb index d852c25e00..1026ea45f4 100644 --- a/spec/forms/journeys/additional_payments_for_teaching/itt_academic_year_form_spec.rb +++ b/spec/forms/journeys/additional_payments_for_teaching/itt_academic_year_form_spec.rb @@ -11,9 +11,20 @@ CurrentClaim.new(claims: claims) end + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end + let(:slug) { "itt_year" } - subject(:form) { described_class.new(claim: current_claim, journey: journey, params: params) } + subject(:form) do + described_class.new( + claim: current_claim, + journey_session: journey_session, + journey: journey, + params: params + ) + end context "unpermitted claim param" do let(:params) { ActionController::Parameters.new({slug: slug, claim: {nonsense_id: 1}}) } diff --git a/spec/forms/journeys/additional_payments_for_teaching/nqt_in_academic_year_after_itt_form_spec.rb b/spec/forms/journeys/additional_payments_for_teaching/nqt_in_academic_year_after_itt_form_spec.rb index 3504ba3293..62e9d3df1d 100644 --- a/spec/forms/journeys/additional_payments_for_teaching/nqt_in_academic_year_after_itt_form_spec.rb +++ b/spec/forms/journeys/additional_payments_for_teaching/nqt_in_academic_year_after_itt_form_spec.rb @@ -3,7 +3,11 @@ RSpec.describe Journeys::AdditionalPaymentsForTeaching::NqtInAcademicYearAfterIttForm do before { create(:journey_configuration, :additional_payments) } - let(:additional_payments_journey) { Journeys::AdditionalPaymentsForTeaching } + let(:journey) { Journeys::AdditionalPaymentsForTeaching } + + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end let(:current_claim) { CurrentClaim.new(claims: [claim]) } @@ -13,7 +17,8 @@ describe "#nqt_in_academic_year_after_itt" do subject(:form) do described_class.new( - journey: additional_payments_journey, + journey: journey, + journey_session: journey_session, claim: current_claim, params: params ) @@ -60,7 +65,8 @@ describe "#save" do let(:form) do described_class.new( - journey: additional_payments_journey, + journey: journey, + journey_session: journey_session, claim: current_claim, params: params ) @@ -194,7 +200,8 @@ let(:form) do described_class.new( - journey: additional_payments_journey, + journey: journey, + journey_session: journey_session, claim: current_claim, params: ActionController::Parameters.new({}) ) @@ -235,7 +242,8 @@ let(:form) do described_class.new( - journey: additional_payments_journey, + journey: journey, + journey_session: journey_session, claim: current_claim, params: ActionController::Parameters.new({ journey: "additional-payments" diff --git a/spec/forms/journeys/additional_payments_for_teaching/poor_performance_form_spec.rb b/spec/forms/journeys/additional_payments_for_teaching/poor_performance_form_spec.rb index d3bddafcf1..b296345c2f 100644 --- a/spec/forms/journeys/additional_payments_for_teaching/poor_performance_form_spec.rb +++ b/spec/forms/journeys/additional_payments_for_teaching/poor_performance_form_spec.rb @@ -1,9 +1,12 @@ require "rails_helper" RSpec.describe Journeys::AdditionalPaymentsForTeaching::PoorPerformanceForm do - subject(:form) { described_class.new(claim:, journey:, params:) } + subject(:form) { described_class.new(claim:, journey_session:, journey:, params:) } let(:journey) { Journeys::AdditionalPaymentsForTeaching } + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end let(:ecp_claim) { build(:claim, policy: Policies::EarlyCareerPayments) } let(:lupp_claim) { build(:claim, policy: Policies::LevellingUpPremiumPayments) } let(:claim) { CurrentClaim.new(claims: [ecp_claim, lupp_claim]) } diff --git a/spec/forms/journeys/additional_payments_for_teaching/qualification_details_form_spec.rb b/spec/forms/journeys/additional_payments_for_teaching/qualification_details_form_spec.rb index f4a97923dd..3afa36fea0 100644 --- a/spec/forms/journeys/additional_payments_for_teaching/qualification_details_form_spec.rb +++ b/spec/forms/journeys/additional_payments_for_teaching/qualification_details_form_spec.rb @@ -3,7 +3,11 @@ RSpec.describe Journeys::AdditionalPaymentsForTeaching::QualificationDetailsForm do before { create(:journey_configuration, :additional_payments) } - let(:additional_payments_journey) { Journeys::AdditionalPaymentsForTeaching } + let(:journey) { Journeys::AdditionalPaymentsForTeaching } + + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end let(:early_career_payments_eligibility) do create( @@ -54,6 +58,7 @@ let(:form) do described_class.new( journey: Journeys::AdditionalPaymentsForTeaching, + journey_session: journey_session, claim: current_claim, params: params ) diff --git a/spec/forms/journeys/additional_payments_for_teaching/qualification_form_spec.rb b/spec/forms/journeys/additional_payments_for_teaching/qualification_form_spec.rb index 52f226c498..2f406f14a4 100644 --- a/spec/forms/journeys/additional_payments_for_teaching/qualification_form_spec.rb +++ b/spec/forms/journeys/additional_payments_for_teaching/qualification_form_spec.rb @@ -3,7 +3,11 @@ RSpec.describe Journeys::AdditionalPaymentsForTeaching::QualificationForm, type: :model do before { create(:journey_configuration, :additional_payments) } - let(:additional_payments_journey) { Journeys::AdditionalPaymentsForTeaching } + let(:journey) { Journeys::AdditionalPaymentsForTeaching } + + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end let(:claim) { create(:claim, policy: Policies::EarlyCareerPayments) } @@ -12,7 +16,8 @@ describe "validations" do subject(:form) do described_class.new( - journey: additional_payments_journey, + journey: journey, + journey_session: journey_session, claim: current_claim, params: ActionController::Parameters.new ) @@ -30,7 +35,8 @@ describe "#save" do let(:form) do described_class.new( - journey: additional_payments_journey, + journey: journey, + journey_session: journey_session, claim: current_claim, params: params ) @@ -76,7 +82,8 @@ describe "#backlink_path" do let(:form) do described_class.new( - journey: additional_payments_journey, + journey: journey, + journey_session: journey_session, claim: current_claim, params: ActionController::Parameters.new( { diff --git a/spec/forms/journeys/additional_payments_for_teaching/teaching_subject_now_form_spec.rb b/spec/forms/journeys/additional_payments_for_teaching/teaching_subject_now_form_spec.rb index 6c5e1b1bc3..32481db83a 100644 --- a/spec/forms/journeys/additional_payments_for_teaching/teaching_subject_now_form_spec.rb +++ b/spec/forms/journeys/additional_payments_for_teaching/teaching_subject_now_form_spec.rb @@ -3,6 +3,9 @@ RSpec.describe Journeys::AdditionalPaymentsForTeaching::TeachingSubjectNowForm do before { create(:journey_configuration, :additional_payments) } let(:journey) { Journeys::AdditionalPaymentsForTeaching } + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end let(:eligibility) { create(:early_career_payments_eligibility) } let(:claim) do create( @@ -15,6 +18,7 @@ let(:form) do described_class.new( journey: journey, + journey_session: journey_session, claim: current_claim, params: params ) diff --git a/spec/forms/journeys/teacher_student_loan_reimbursement/leadership_position_form_spec.rb b/spec/forms/journeys/teacher_student_loan_reimbursement/leadership_position_form_spec.rb index 93f73ac37a..e5dcf8e974 100644 --- a/spec/forms/journeys/teacher_student_loan_reimbursement/leadership_position_form_spec.rb +++ b/spec/forms/journeys/teacher_student_loan_reimbursement/leadership_position_form_spec.rb @@ -21,6 +21,10 @@ let(:current_claim) { CurrentClaim.new(claims: [claim]) } + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end + let(:params) do ActionController::Parameters.new( claim: {had_leadership_position: had_leadership_position} @@ -28,7 +32,12 @@ end let(:form) do - described_class.new(journey: journey, claim: current_claim, params: params) + described_class.new( + journey: journey, + journey_session: journey_session, + claim: current_claim, + params: params + ) end describe "validations" do diff --git a/spec/forms/journeys/teacher_student_loan_reimbursement/mostly_performed_leadership_duties_form_spec.rb b/spec/forms/journeys/teacher_student_loan_reimbursement/mostly_performed_leadership_duties_form_spec.rb index 500dbc211a..e3b801c0d7 100644 --- a/spec/forms/journeys/teacher_student_loan_reimbursement/mostly_performed_leadership_duties_form_spec.rb +++ b/spec/forms/journeys/teacher_student_loan_reimbursement/mostly_performed_leadership_duties_form_spec.rb @@ -19,6 +19,10 @@ ) end + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end + let(:current_claim) { CurrentClaim.new(claims: [claim]) } let(:params) do @@ -30,7 +34,12 @@ end let(:form) do - described_class.new(journey: journey, claim: current_claim, params: params) + described_class.new( + journey: journey, + journey_session: journey_session, + claim: current_claim, + params: params + ) end describe "validations" do diff --git a/spec/forms/journeys/teacher_student_loan_reimbursement/qts_year_form_spec.rb b/spec/forms/journeys/teacher_student_loan_reimbursement/qts_year_form_spec.rb index ec5e01cfaa..d31e363a79 100644 --- a/spec/forms/journeys/teacher_student_loan_reimbursement/qts_year_form_spec.rb +++ b/spec/forms/journeys/teacher_student_loan_reimbursement/qts_year_form_spec.rb @@ -1,9 +1,14 @@ require "rails_helper" RSpec.describe Journeys::TeacherStudentLoanReimbursement::QtsYearForm, type: :model do - subject(:form) { described_class.new(claim:, journey:, params:) } + subject(:form) do + described_class.new(claim:, journey_session:, journey:, params:) + end let(:journey) { Journeys::TeacherStudentLoanReimbursement } + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end let(:claim) { CurrentClaim.new(claims: [build(:claim, policy: Policies::StudentLoans)]) } let(:slug) { "qts-year" } let(:params) { ActionController::Parameters.new({slug:, claim: claim_params}) } diff --git a/spec/forms/journeys/teacher_student_loan_reimbursement/qualification_details_form_spec.rb b/spec/forms/journeys/teacher_student_loan_reimbursement/qualification_details_form_spec.rb index f1821f87f8..d8ac323795 100644 --- a/spec/forms/journeys/teacher_student_loan_reimbursement/qualification_details_form_spec.rb +++ b/spec/forms/journeys/teacher_student_loan_reimbursement/qualification_details_form_spec.rb @@ -20,9 +20,16 @@ CurrentClaim.new(claims: [student_loans_claim]) end + let(:journey) { Journeys::TeacherStudentLoanReimbursement } + + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end + let(:form) do described_class.new( - journey: Journeys::TeacherStudentLoanReimbursement, + journey: journey, + journey_session: journey_session, claim: current_claim, params: params ) diff --git a/spec/forms/journeys/teacher_student_loan_reimbursement/still_teaching_form_spec.rb b/spec/forms/journeys/teacher_student_loan_reimbursement/still_teaching_form_spec.rb index d4bbfcd46d..dfe1f8f52f 100644 --- a/spec/forms/journeys/teacher_student_loan_reimbursement/still_teaching_form_spec.rb +++ b/spec/forms/journeys/teacher_student_loan_reimbursement/still_teaching_form_spec.rb @@ -8,10 +8,15 @@ let(:claim) { create(:claim, policy: Policies::StudentLoans, eligibility:) } let(:current_claim) { CurrentClaim.new(claims: [claim]) } let(:claim_params) { {} } + let(:journey) { Journeys::TeacherStudentLoanReimbursement } + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end subject(:form) do described_class.new( - journey: Journeys::TeacherStudentLoanReimbursement, + journey: journey, + journey_session: journey_session, claim: current_claim, params: ActionController::Parameters.new(claim: claim_params) ) diff --git a/spec/forms/journeys/teacher_student_loan_reimbursement/subjects_taught_form_spec.rb b/spec/forms/journeys/teacher_student_loan_reimbursement/subjects_taught_form_spec.rb index 6ca8ee6bed..1005aa7b37 100644 --- a/spec/forms/journeys/teacher_student_loan_reimbursement/subjects_taught_form_spec.rb +++ b/spec/forms/journeys/teacher_student_loan_reimbursement/subjects_taught_form_spec.rb @@ -1,9 +1,14 @@ require "rails_helper" RSpec.describe Journeys::TeacherStudentLoanReimbursement::SubjectsTaughtForm, type: :model do - subject(:form) { described_class.new(claim:, journey:, params:) } + subject(:form) do + described_class.new(claim:, journey_session:, journey:, params:) + end let(:journey) { Journeys::TeacherStudentLoanReimbursement } + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end let(:claim) { CurrentClaim.new(claims: [build(:claim, policy: Policies::StudentLoans)]) } let(:slug) { "subjects-taught" } let(:params) { ActionController::Parameters.new({slug:, claim: claim_params}) } diff --git a/spec/forms/mobile_number_form_spec.rb b/spec/forms/mobile_number_form_spec.rb index 3688eda4d4..681be26456 100644 --- a/spec/forms/mobile_number_form_spec.rb +++ b/spec/forms/mobile_number_form_spec.rb @@ -13,6 +13,10 @@ end end + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end + let(:current_claim) { CurrentClaim.new(claims: claims) } let(:params) do @@ -20,7 +24,12 @@ end let(:form) do - described_class.new(journey: journey, claim: current_claim, params: params) + described_class.new( + journey: journey, + journey_session: journey_session, + claim: current_claim, + params: params + ) end describe "validations" do diff --git a/spec/forms/mobile_verification_form_spec.rb b/spec/forms/mobile_verification_form_spec.rb index deecdbe190..db0c29e489 100644 --- a/spec/forms/mobile_verification_form_spec.rb +++ b/spec/forms/mobile_verification_form_spec.rb @@ -14,6 +14,10 @@ let(:current_claim) { CurrentClaim.new(claims: claims) } + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end + let(:params) do ActionController::Parameters.new( claim: { @@ -23,7 +27,12 @@ end let(:form) do - described_class.new(journey: journey, claim: current_claim, params: params) + described_class.new( + journey: journey, + journey_session: journey_session, + claim: current_claim, + params: params + ) end around do |example| diff --git a/spec/forms/personal_details_form_spec.rb b/spec/forms/personal_details_form_spec.rb index 5bdd365dcb..f868fc22cf 100644 --- a/spec/forms/personal_details_form_spec.rb +++ b/spec/forms/personal_details_form_spec.rb @@ -12,10 +12,21 @@ CurrentClaim.new(claims: claims) end + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end + let(:slug) { "personal-details" } let(:params) { {} } - subject(:form) { described_class.new(claim: current_claim, journey: journey, params: ActionController::Parameters.new(slug:, claim: params)) } + subject(:form) do + described_class.new( + claim: current_claim, + journey_session: journey_session, + journey: journey, + params: ActionController::Parameters.new(slug:, claim: params) + ) + end context "unpermitted claim param" do let(:params) { {nonsense_id: 1} } diff --git a/spec/forms/postcode_search_form_spec.rb b/spec/forms/postcode_search_form_spec.rb index ebdbc2b369..4072062cbe 100644 --- a/spec/forms/postcode_search_form_spec.rb +++ b/spec/forms/postcode_search_form_spec.rb @@ -1,10 +1,13 @@ require "rails_helper" RSpec.describe PostcodeSearchForm, type: :model do - subject { described_class.new(claim:, journey:, params:) } + subject { described_class.new(claim:, journey:, params:, journey_session:) } let(:claim) { CurrentClaim.new(claims: [create(:claim)]) } let(:journey) { Journeys::AdditionalPaymentsForTeaching } + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end let(:params) { ActionController::Parameters.new } before do diff --git a/spec/forms/provide_mobile_number_form_spec.rb b/spec/forms/provide_mobile_number_form_spec.rb index 1f56f3c2cf..8fe7be9117 100644 --- a/spec/forms/provide_mobile_number_form_spec.rb +++ b/spec/forms/provide_mobile_number_form_spec.rb @@ -14,8 +14,18 @@ let(:slug) { "provide-mobile-number" } let(:params) { ActionController::Parameters.new } + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end - subject(:form) { described_class.new(claim: current_claim, journey: journey, params: params) } + subject(:form) do + described_class.new( + claim: current_claim, + journey_session: journey_session, + journey: journey, + params: params + ) + end context "unpermitted claim param" do let(:params) { ActionController::Parameters.new({slug: slug, claim: {nonsense_id: 1}}) } diff --git a/spec/forms/reset_claim_form_spec.rb b/spec/forms/reset_claim_form_spec.rb index 2822fd6347..fc58df1278 100644 --- a/spec/forms/reset_claim_form_spec.rb +++ b/spec/forms/reset_claim_form_spec.rb @@ -2,11 +2,14 @@ RSpec.describe ResetClaimForm, type: :model do describe "#save" do - subject { described_class.new(claim:, journey:, params:).save } + subject { described_class.new(claim:, journey:, params:, journey_session:).save } let(:claim) { double } - let(:journey) { double } + let(:journey) { Journeys::TeacherStudentLoanReimbursement } let(:params) { nil } + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end it { is_expected.to be_truthy } end diff --git a/spec/forms/select_email_form_spec.rb b/spec/forms/select_email_form_spec.rb index c667cdcfb8..5d2be0bdd3 100644 --- a/spec/forms/select_email_form_spec.rb +++ b/spec/forms/select_email_form_spec.rb @@ -1,9 +1,12 @@ require "rails_helper" RSpec.describe SelectEmailForm, type: :model do - subject(:form) { described_class.new(claim:, journey:, params:) } + subject(:form) { described_class.new(claim:, journey_session:, journey:, params:) } let(:journey) { Journeys::TeacherStudentLoanReimbursement } + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end let(:claim) { CurrentClaim.new(claims: [build(:claim, policy: Policies::StudentLoans)]) } let(:slug) { "select-email" } let(:params) { ActionController::Parameters.new({slug:, claim: claim_params}) } diff --git a/spec/forms/select_mobile_form_spec.rb b/spec/forms/select_mobile_form_spec.rb index 7912f4602e..dd9f382ba7 100644 --- a/spec/forms/select_mobile_form_spec.rb +++ b/spec/forms/select_mobile_form_spec.rb @@ -17,12 +17,21 @@ let(:current_claim) { CurrentClaim.new(claims: claims) } + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end + let(:params) do ActionController::Parameters.new(claim: {mobile_check: mobile_check}) end let(:form) do - described_class.new(journey: journey, claim: current_claim, params: params) + described_class.new( + journey: journey, + journey_session: journey_session, + claim: current_claim, + params: params + ) end describe "validations" do diff --git a/spec/forms/sign_in_or_continue_form_spec.rb b/spec/forms/sign_in_or_continue_form_spec.rb index 58eb769a44..7f475300f7 100644 --- a/spec/forms/sign_in_or_continue_form_spec.rb +++ b/spec/forms/sign_in_or_continue_form_spec.rb @@ -15,8 +15,17 @@ CurrentClaim.new(claims: claims) end + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end + let(:form) do - described_class.new(journey: journey, claim: current_claim, params: params) + described_class.new( + journey: journey, + journey_session: journey_session, + claim: current_claim, + params: params + ) end describe "validations" do diff --git a/spec/forms/supply_teacher_form_spec.rb b/spec/forms/supply_teacher_form_spec.rb index d5f740af42..e9219cad61 100644 --- a/spec/forms/supply_teacher_form_spec.rb +++ b/spec/forms/supply_teacher_form_spec.rb @@ -5,6 +5,10 @@ let(:journey) { Journeys::AdditionalPaymentsForTeaching } + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end + let(:current_claim) do claims = journey::POLICIES.map { |policy| create(:claim, policy:) } CurrentClaim.new(claims:) @@ -12,7 +16,14 @@ let(:slug) { "supply-teacher" } - subject(:form) { described_class.new(claim: current_claim, journey:, params:) } + subject(:form) do + described_class.new( + claim: current_claim, + journey_session:, + journey:, + params: + ) + end context "unpermitted claim param" do let(:params) { ActionController::Parameters.new({slug:, claim: {random_param: 1}}) } diff --git a/spec/forms/teacher_reference_number_form_spec.rb b/spec/forms/teacher_reference_number_form_spec.rb index b6778c98c9..e50c0883fe 100644 --- a/spec/forms/teacher_reference_number_form_spec.rb +++ b/spec/forms/teacher_reference_number_form_spec.rb @@ -9,6 +9,10 @@ let(:current_claim) { CurrentClaim.new(claims: [claim]) } + let(:journey_session) do + build(:journeys_session, journey: journey::ROUTING_NAME) + end + let(:params) do ActionController::Parameters.new( claim: { @@ -20,6 +24,7 @@ let(:form) do described_class.new( journey: journey, + journey_session: journey_session, claim: current_claim, params: params ) diff --git a/spec/models/journeys/additional_payments_for_teaching/slug_sequence_spec.rb b/spec/models/journeys/additional_payments_for_teaching/slug_sequence_spec.rb index b2da9263f4..78132c2f1d 100644 --- a/spec/models/journeys/additional_payments_for_teaching/slug_sequence_spec.rb +++ b/spec/models/journeys/additional_payments_for_teaching/slug_sequence_spec.rb @@ -1,7 +1,7 @@ require "rails_helper" RSpec.describe Journeys::AdditionalPaymentsForTeaching::SlugSequence do - subject(:slug_sequence) { described_class.new(current_claim) } + subject(:slug_sequence) { described_class.new(current_claim, journey_session) } let(:eligibility) { create(:early_career_payments_eligibility, :eligible) } let(:eligibility_lup) { create(:levelling_up_premium_payments_eligibility, :eligible) } @@ -9,6 +9,7 @@ let(:claim) { create(:claim, :skipped_tid, policy: Policies::EarlyCareerPayments, academic_year: AcademicYear.new(2021), eligibility: eligibility, logged_in_with_tid:, details_check:, dqt_teacher_status:, qualifications_details_check:) } let(:lup_claim) { create(:claim, :skipped_tid, policy: Policies::LevellingUpPremiumPayments, academic_year: AcademicYear.new(2021), eligibility: eligibility_lup) } let(:current_claim) { CurrentClaim.new(claims: [claim, lup_claim]) } + let(:journey_session) { build(:journeys_session) } let(:teacher_id_enabled) { true } let(:logged_in_with_tid) { nil } let(:details_check) { nil } @@ -308,8 +309,9 @@ let(:ecp_claim) { build(:claim, policy: Policies::EarlyCareerPayments, eligibility_trait: ecp_eligibility) } let(:lup_claim) { build(:claim, policy: Policies::LevellingUpPremiumPayments, eligibility_trait: lup_eligibility) } let(:current_claim) { CurrentClaim.new(claims: [ecp_claim, lup_claim]) } + let(:journey_session) { build(:journeys_session) } - subject { described_class.new(current_claim).slugs } + subject { described_class.new(current_claim, journey_session).slugs } context "current claim is :eligible_now" do let(:ecp_eligibility) { :eligible_later } diff --git a/spec/models/journeys/additional_payments_for_teaching_spec.rb b/spec/models/journeys/additional_payments_for_teaching_spec.rb index 47c51c15e6..6790447fff 100644 --- a/spec/models/journeys/additional_payments_for_teaching_spec.rb +++ b/spec/models/journeys/additional_payments_for_teaching_spec.rb @@ -37,8 +37,16 @@ let(:completed_slugs) { [:test] } let(:current_slug) { [:test2] } let(:claim) { double } + let(:journey_session) { build(:journeys_session) } - subject(:page_sequence) { described_class.page_sequence_for_claim(claim, completed_slugs, current_slug) } + subject(:page_sequence) do + described_class.page_sequence_for_claim( + claim, + journey_session, + completed_slugs, + current_slug + ) + end it { is_expected.to be_a(Journeys::PageSequence) } @@ -49,7 +57,9 @@ end it "creates a slug sequence" do - expect(Journeys::AdditionalPaymentsForTeaching::SlugSequence).to receive(:new).with(claim) + expect(Journeys::AdditionalPaymentsForTeaching::SlugSequence).to( + receive(:new).with(claim, journey_session) + ) page_sequence end end diff --git a/spec/models/journeys/teacher_student_loan_reimbursement/slug_sequence_spec.rb b/spec/models/journeys/teacher_student_loan_reimbursement/slug_sequence_spec.rb index bc4f643077..cd80e31a49 100644 --- a/spec/models/journeys/teacher_student_loan_reimbursement/slug_sequence_spec.rb +++ b/spec/models/journeys/teacher_student_loan_reimbursement/slug_sequence_spec.rb @@ -1,11 +1,12 @@ require "rails_helper" RSpec.describe Journeys::TeacherStudentLoanReimbursement::SlugSequence do - subject(:slug_sequence) { described_class.new(current_claim) } + subject(:slug_sequence) { described_class.new(current_claim, journey_session) } let(:eligibility) { create(:student_loans_eligibility, :eligible) } let(:claim) { build(:claim, eligibility:, logged_in_with_tid:, details_check:, qualifications_details_check:, dqt_teacher_status:) } let(:current_claim) { CurrentClaim.new(claims: [claim]) } + let(:journey_session) { build(:journeys_session) } let(:logged_in_with_tid) { nil } let(:details_check) { nil } let(:qualifications_details_check) { nil } diff --git a/spec/models/journeys/teacher_student_loan_reimbursement_spec.rb b/spec/models/journeys/teacher_student_loan_reimbursement_spec.rb index c3de708c38..bf6bf1a3ae 100644 --- a/spec/models/journeys/teacher_student_loan_reimbursement_spec.rb +++ b/spec/models/journeys/teacher_student_loan_reimbursement_spec.rb @@ -36,9 +36,17 @@ describe ".page_sequence_for_claim" do let(:completed_slugs) { [:test] } let(:current_slug) { [:test2] } + let(:journey_session) { build(:journeys_session) } let(:claim) { double } - subject(:page_sequence) { described_class.page_sequence_for_claim(claim, completed_slugs, current_slug) } + subject(:page_sequence) do + described_class.page_sequence_for_claim( + claim, + journey_session, + completed_slugs, + current_slug + ) + end it { is_expected.to be_a(Journeys::PageSequence) } @@ -49,7 +57,10 @@ end it "creates a slug sequence" do - expect(Journeys::TeacherStudentLoanReimbursement::SlugSequence).to receive(:new).with(claim) + expect(Journeys::TeacherStudentLoanReimbursement::SlugSequence).to( + receive(:new).with(claim, journey_session) + ) + page_sequence end end diff --git a/spec/support/feature_helpers.rb b/spec/support/feature_helpers.rb index 2f53966748..465e057fec 100644 --- a/spec/support/feature_helpers.rb +++ b/spec/support/feature_helpers.rb @@ -126,7 +126,9 @@ def jump_to_claim_journey_page(claim, slug) def set_slug_sequence_in_session(claim, slug) current_claim = CurrentClaim.new(claims: [claim]) - slug_sequence = Journeys.for_policy(claim.policy).slug_sequence.new(current_claim).slugs + journey = Journeys.for_policy(claim.policy) + journey_session = build(:journeys_session, journey: journey::ROUTING_NAME) + slug_sequence = journey.slug_sequence.new(current_claim, journey_session).slugs slug_index = slug_sequence.index(slug) visited_slugs = slug_sequence.slice(0, slug_index) diff --git a/spec/support/request_helpers.rb b/spec/support/request_helpers.rb index b0f45167ec..ddaa7cff1f 100644 --- a/spec/support/request_helpers.rb +++ b/spec/support/request_helpers.rb @@ -29,7 +29,9 @@ def sign_in_to_admin_with_role(*) def set_slug_sequence_in_session(claim, slug) current_claim = CurrentClaim.new(claims: [claim]) - slug_sequence = Journeys.for_policy(claim.policy).slug_sequence.new(current_claim).slugs + journey = Journeys.for_policy(claim.policy) + journey_session = build(:journeys_session, journey: journey::ROUTING_NAME) + slug_sequence = journey.slug_sequence.new(current_claim, journey_session).slugs slug_index = slug_sequence.index(slug) visited_slugs = slug_sequence.slice(0, slug_index)