diff --git a/app/controllers/claims_controller.rb b/app/controllers/claims_controller.rb index e64f52bc07..d5e9415d6b 100644 --- a/app/controllers/claims_controller.rb +++ b/app/controllers/claims_controller.rb @@ -49,7 +49,6 @@ def redirect_to_existing_claim_journey params[:journey] = new_journey::ROUTING_NAME new_page_sequence = new_journey.page_sequence_for_claim( - current_claim, journey_session, session[:slugs], params[:slug] @@ -101,7 +100,6 @@ def claim_ineligible? def page_sequence @page_sequence ||= journey.page_sequence_for_claim( - current_claim, journey_session, session[:slugs], params[:slug] 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 86ce399646..4c04c009d9 100644 --- a/app/models/journeys/additional_payments_for_teaching/slug_sequence.rb +++ b/app/models/journeys/additional_payments_for_teaching/slug_sequence.rb @@ -75,13 +75,11 @@ class SlugSequence RESULTS_SLUGS ).freeze - attr_reader :claim, :journey_session + attr_reader :journey_session delegate :answers, to: :journey_session - # Really this is a combined CurrentClaim - def initialize(claim, journey_session) - @claim = claim + def initialize(journey_session) @journey_session = journey_session end @@ -178,8 +176,11 @@ def self.start_page_url private def personal_details_form + # FIXME RL: forms expect a claim argument even thought they don't use it + # this will be removed as part of no longer creating a claim at the + # start of the journey work PersonalDetailsForm.new( - claim:, + claim: nil, journey_session: journey_session, journey: Journeys::AdditionalPaymentsForTeaching, params: ActionController::Parameters.new diff --git a/app/models/journeys/base.rb b/app/models/journeys/base.rb index eaa5bafb17..95b5fee631 100644 --- a/app/models/journeys/base.rb +++ b/app/models/journeys/base.rb @@ -45,10 +45,9 @@ def forms defined?(self::FORMS) ? self::FORMS : {} end - def page_sequence_for_claim(claim, journey_session, completed_slugs, current_slug) + def page_sequence_for_claim(journey_session, completed_slugs, current_slug) PageSequence.new( - claim, - slug_sequence.new(claim, journey_session), + slug_sequence.new(journey_session), completed_slugs, current_slug, journey_session diff --git a/app/models/journeys/page_sequence.rb b/app/models/journeys/page_sequence.rb index 48de328772..d6fe3bcead 100644 --- a/app/models/journeys/page_sequence.rb +++ b/app/models/journeys/page_sequence.rb @@ -3,13 +3,12 @@ # Used to model the sequence of pages that make up the claim process. module Journeys class PageSequence - attr_reader :claim, :current_slug, :completed_slugs + attr_reader :current_slug, :completed_slugs DEAD_END_SLUGS = %w[complete existing-session eligible-later future-eligibility ineligible] OPTIONAL_SLUGS = %w[postcode-search select-home-address reset-claim] - def initialize(claim, slug_sequence, completed_slugs, current_slug, journey_session) - @claim = claim + def initialize(slug_sequence, completed_slugs, current_slug, journey_session) @current_slug = current_slug @slug_sequence = slug_sequence @completed_slugs = completed_slugs @@ -75,7 +74,7 @@ def can_skip_next_slug? end def lup_policy_and_trainee_teacher_at_lup_school? - Policies::LevellingUpPremiumPayments.in?(claim.policies) && lup_teacher_at_lup_school + journey == Journeys::AdditionalPaymentsForTeaching && lup_teacher_at_lup_school end def lup_teacher_at_lup_school 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 c158d573f7..66607209b4 100644 --- a/app/models/journeys/teacher_student_loan_reimbursement/slug_sequence.rb +++ b/app/models/journeys/teacher_student_loan_reimbursement/slug_sequence.rb @@ -61,18 +61,17 @@ class SlugSequence RESULTS_SLUGS ).freeze - attr_reader :claim, :journey_session + attr_reader :journey_session delegate :answers, to: :journey_session - def initialize(claim, journey_session) - @claim = claim + def initialize(journey_session) @journey_session = journey_session end def slugs SLUGS.dup.tap do |sequence| - if !Journeys.for_policy(claim.policy).configuration.teacher_id_enabled? + if !Journeys::TeacherStudentLoanReimbursement.configuration.teacher_id_enabled? sequence.delete("sign-in-or-continue") sequence.delete("reset-claim") sequence.delete("qualification-details") @@ -134,7 +133,7 @@ def self.start_page_url def personal_details_form PersonalDetailsForm.new( - claim:, + claim: nil, journey_session: journey_session, journey: Journeys::TeacherStudentLoanReimbursement, params: ActionController::Parameters.new diff --git a/spec/features/admin_claim_tasks_update_with_dqt_api_spec.rb b/spec/features/admin_claim_tasks_update_with_dqt_api_spec.rb index 17e467897d..2e33635160 100644 --- a/spec/features/admin_claim_tasks_update_with_dqt_api_spec.rb +++ b/spec/features/admin_claim_tasks_update_with_dqt_api_spec.rb @@ -32,7 +32,6 @@ def claimant_submits_claim(claim_attributes:, answers:, post_submission_claim_at claim.save! jump_to_claim_journey_page( - claim: claim, slug: "check-your-answers", journey_session: journey_session ) diff --git a/spec/features/auto_populating_home_address_from_postcode_search_spec.rb b/spec/features/auto_populating_home_address_from_postcode_search_spec.rb index 2c0e1f6b98..cf53ca3ab2 100644 --- a/spec/features/auto_populating_home_address_from_postcode_search_spec.rb +++ b/spec/features/auto_populating_home_address_from_postcode_search_spec.rb @@ -258,10 +258,6 @@ end context "with a supplied postcode" do - let(:claim) do - Claim.by_policy(Policies::EarlyCareerPayments).order(:created_at).last - end - let(:journey_session) do Journeys::AdditionalPaymentsForTeaching::Session.order(:created_at).last end @@ -270,9 +266,6 @@ create(:journey_configuration, :additional_payments) start_early_career_payments_claim - claim.eligibility.update!(attributes_for(:early_career_payments_eligibility, :eligible)) - claim.save! - journey_session.answers.assign_attributes( attributes_for( :additional_payments_answers, @@ -287,9 +280,13 @@ end scenario "with Ordnance Survey API data" do - expect(claim.valid?(:submit)).to eq false + expect( + Journeys::AdditionalPaymentsForTeaching::ClaimSubmissionForm.new( + journey_session: journey_session + ).valid? + ).to eq false + jump_to_claim_journey_page( - claim: claim, slug: "postcode-search", journey_session: journey_session ) @@ -322,9 +319,12 @@ end scenario "Claimant cannot find the correct address so chooses to manually enter address" do - expect(claim.valid?(:submit)).to eq false + expect( + Journeys::AdditionalPaymentsForTeaching::ClaimSubmissionForm.new( + journey_session: journey_session + ).valid? + ).to eq false jump_to_claim_journey_page( - claim: claim, slug: "postcode-search", journey_session: journey_session ) @@ -368,9 +368,13 @@ # Bugfix - did cause an exception after pressing back scenario "Claimant cannot find the correct address so chooses to manually enter address, presses back before filling anything to go to the postcode search again" do - expect(claim.valid?(:submit)).to eq false + expect( + Journeys::AdditionalPaymentsForTeaching::ClaimSubmissionForm.new( + journey_session: journey_session + ).valid? + ).to eq false + jump_to_claim_journey_page( - claim: claim, slug: "postcode-search", journey_session: journey_session ) @@ -396,9 +400,13 @@ end scenario "Claimant decides they want to change the POSTCODE from the 'select-home-address' screen" do - expect(claim.valid?(:submit)).to eq false + expect( + Journeys::AdditionalPaymentsForTeaching::ClaimSubmissionForm.new( + journey_session: journey_session + ).valid? + ).to eq false + jump_to_claim_journey_page( - claim: claim, slug: "postcode-search", journey_session: journey_session ) @@ -468,9 +476,13 @@ end scenario "Ordanance Survery Client raise a ResponseError" do - expect(claim.valid?(:submit)).to eq false + expect( + Journeys::AdditionalPaymentsForTeaching::ClaimSubmissionForm.new( + journey_session: journey_session + ).valid? + ).to eq false + jump_to_claim_journey_page( - claim: claim, slug: "postcode-search", journey_session: journey_session ) diff --git a/spec/features/changing_answers_spec.rb b/spec/features/changing_answers_spec.rb index f6f8dc2138..3a8bd108e4 100644 --- a/spec/features/changing_answers_spec.rb +++ b/spec/features/changing_answers_spec.rb @@ -12,9 +12,7 @@ let(:ecp_school) { create(:school, :early_career_payments_eligible) } scenario "Teacher changes an answer which is not a dependency of any of the other answers they've given, remaining eligible" do - claim = start_student_loans_claim - claim.update!(attributes_for(:claim, :submittable)) - claim.eligibility.update!(attributes_for(:student_loans_eligibility, :eligible, current_school_id: student_loans_school.id, claim_school_id: student_loans_school.id)) + start_student_loans_claim session = Journeys::TeacherStudentLoanReimbursement::Session.order(:created_at).last session.answers.assign_attributes( @@ -23,7 +21,6 @@ session.save! jump_to_claim_journey_page( - claim:, journey_session: session, slug: "check-your-answers" ) @@ -45,7 +42,7 @@ end scenario "Teacher changes an answer which is not a dependency of any of the other answers they've given, becoming ineligible" do - claim = start_student_loans_claim + start_student_loans_claim session = Journeys::TeacherStudentLoanReimbursement::Session.order(:created_at).last session.answers.assign_attributes( attributes_for( @@ -58,7 +55,6 @@ ) session.save! jump_to_claim_journey_page( - claim:, slug: "check-your-answers", journey_session: session ) @@ -77,9 +73,7 @@ end scenario "Teacher changes an answer which is a dependency of some of the subsequent answers they've given, remaining eligible" do - claim = start_student_loans_claim - claim.update!(attributes_for(:claim, :submittable)) - claim.eligibility.update!(attributes_for(:student_loans_eligibility, :eligible, current_school_id: student_loans_school.id)) + start_student_loans_claim session = Journeys::TeacherStudentLoanReimbursement::Session.order(:created_at).last session.answers.assign_attributes( @@ -88,7 +82,6 @@ session.save! jump_to_claim_journey_page( - claim:, slug: "check-your-answers", journey_session: session ) @@ -128,9 +121,7 @@ end scenario "Teacher changes an answer which is a dependency of some of the subsequent answers they've given, making them ineligible" do - claim = start_student_loans_claim - claim.update!(attributes_for(:claim, :submittable)) - claim.eligibility.update!(attributes_for(:student_loans_eligibility, :eligible, current_school_id: student_loans_school.id, claim_school_id: student_loans_school.id)) + start_student_loans_claim session = Journeys::TeacherStudentLoanReimbursement::Session.order(:created_at).last session.answers.assign_attributes( attributes_for( @@ -142,7 +133,6 @@ session.save! jump_to_claim_journey_page( - claim: claim, slug: "check-your-answers", journey_session: session ) @@ -165,9 +155,7 @@ end scenario "Teacher edits but does not change an answer which is a dependency of some of the subsequent answers they've given" do - claim = start_student_loans_claim - claim.update!(attributes_for(:claim, :submittable)) - claim.eligibility.update!(attributes_for(:student_loans_eligibility, :eligible, current_school_id: student_loans_school.id, claim_school_id: student_loans_school.id)) + start_student_loans_claim session = Journeys::TeacherStudentLoanReimbursement::Session.order(:created_at).last session.answers.assign_attributes( @@ -176,7 +164,6 @@ session.save! jump_to_claim_journey_page( - claim: claim, slug: "check-your-answers", journey_session: session ) @@ -198,7 +185,7 @@ end scenario "Teacher edits personal details, triggering the update of student loan details" do - claim = start_student_loans_claim + start_student_loans_claim journey_session = Journeys::TeacherStudentLoanReimbursement::Session.order(:created_at).last journey_session.update!( @@ -214,7 +201,6 @@ answers = journey_session.answers jump_to_claim_journey_page( - claim: claim, slug: "check-your-answers", journey_session: journey_session ) @@ -240,16 +226,13 @@ end context "User changes fields that aren't related to eligibility" do - let!(:claim) { start_student_loans_claim } - let(:eligibility) { claim.eligibility } let(:journey_session) do Journeys::TeacherStudentLoanReimbursement::Session.order(:created_at).last end let(:answers) { journey_session.answers } before do - claim.update!(attributes_for(:claim, :submittable)) - eligibility.update!(attributes_for(:student_loans_eligibility, :eligible, current_school_id: student_loans_school.id, claim_school_id: student_loans_school.id)) + start_student_loans_claim journey_session.update!( answers: attributes_for( :student_loans_answers, @@ -258,7 +241,6 @@ ) ) jump_to_claim_journey_page( - claim: claim, slug: "check-your-answers", journey_session: journey_session ) @@ -283,9 +265,7 @@ end scenario "user can change the answer to identity details" do - claim.update!(govuk_verify_fields: []) jump_to_claim_journey_page( - claim: claim, slug: "check-your-answers", journey_session: journey_session ) @@ -311,7 +291,6 @@ scenario "user can change the answer to payment details" do jump_to_claim_journey_page( - claim: claim, slug: "check-your-answers", journey_session: journey_session ) @@ -349,16 +328,12 @@ end describe "Teacher changes a field that requires OTP validation" do - let!(:claim) { start_early_career_payments_claim } - let(:eligibility) { claim.eligibility } let(:session) do Journeys::AdditionalPaymentsForTeaching::Session.order(:created_at).last end before do - claim.update!(attributes_for(:claim, :submittable)) - eligibility.update!(attributes_for(:early_career_payments_eligibility, :eligible, current_school_id: ecp_school.id)) - claim.update!(personal_details_attributes) + start_early_career_payments_claim session.answers.assign_attributes( attributes_for( @@ -369,7 +344,6 @@ session.save! jump_to_claim_journey_page( - claim: claim, slug: "check-your-answers", journey_session: session ) @@ -399,8 +373,12 @@ fill_in "claim_one_time_password", with: otp_in_mail_sent click_on "Confirm" - expect(claim.reload.email_verified).to eq true - expect(claim.submittable?).to be true + expect(session.reload.answers.email_verified).to eq true + expect( + Journeys::AdditionalPaymentsForTeaching::ClaimSubmissionForm.new( + journey_session: session + ) + ).to be_valid expect(page).to have_content("Check your answers before sending your application") end end @@ -453,7 +431,11 @@ expect(page).not_to have_text("Some places are both a bank and a building society") expect(session.reload.answers.mobile_verified).to eq true - expect(claim.submittable?).to be true + expect( + Journeys::AdditionalPaymentsForTeaching::ClaimSubmissionForm.new( + journey_session: session + ) + ).to be_valid expect(page).to have_content("Check your answers before sending your application") end end @@ -505,7 +487,11 @@ expect(page).not_to have_text("Some places are both a bank and a building society") expect(session.reload.answers.mobile_verified).to eq true - expect(claim.submittable?).to be true + expect( + Journeys::AdditionalPaymentsForTeaching::ClaimSubmissionForm.new( + journey_session: session + ) + ).to be_valid expect(page).to have_content("Check your answers before sending your application") end end diff --git a/spec/features/claim_journey_does_not_get_cached_spec.rb b/spec/features/claim_journey_does_not_get_cached_spec.rb index 0d86161b61..f047aa9c51 100644 --- a/spec/features/claim_journey_does_not_get_cached_spec.rb +++ b/spec/features/claim_journey_does_not_get_cached_spec.rb @@ -4,34 +4,29 @@ before { create(:journey_configuration, :student_loans) } it "redirects the user to the start of the claim journey if they go back after the claim is completed" do - claim = start_student_loans_claim - claim.update!(attributes_for(:claim, :submittable)) + start_student_loans_claim journey_session = Journeys::TeacherStudentLoanReimbursement::Session.last journey_session.update!( answers: attributes_for(:student_loans_answers, :submittable) ) - claim.eligibility = create(:student_loans_eligibility, :eligible) - claim.save! jump_to_claim_journey_page( - claim: claim, slug: "check-your-answers", journey_session: journey_session ) - expect(page).to have_text(claim.first_name) + expect(page).to have_text(journey_session.answers.first_name) click_on "Confirm and send" expect(current_path).to eq(claim_confirmation_path(Journeys::TeacherStudentLoanReimbursement::ROUTING_NAME)) jump_to_claim_journey_page( - claim: claim, slug: "check-your-answers", journey_session: journey_session ) - expect(page).to_not have_text(claim.first_name) + expect(page).to_not have_text(journey_session.answers.first_name) expect(page).to have_text("Use DfE Identity to sign in") end end diff --git a/spec/features/claim_with_mobile_sms_otp_spec.rb b/spec/features/claim_with_mobile_sms_otp_spec.rb index 1e3fa5194f..0d6d6159bf 100644 --- a/spec/features/claim_with_mobile_sms_otp_spec.rb +++ b/spec/features/claim_with_mobile_sms_otp_spec.rb @@ -3,33 +3,6 @@ RSpec.feature "GOVUK Nofity SMS sends OTP" do let(:notify) { instance_double("NotifySmsMessage", deliver!: true) } - let(:early_career_payments_personal_details_attributes) do - { - first_name: "Shona", - surname: "Riveria", - date_of_birth: Date.new(1987, 11, 30), - national_insurance_number: "AG749900B", - address_line_1: "105A", - address_line_2: "Cheapstow Road", - address_line_3: "Cheapstow", - address_line_4: "Bristol", - postcode: "BS1 4BS", - email_address: "s.riveria80s@example.com", - provide_mobile_number: true, - email_verified: true - } - end - let(:student_loans_personal_details_attributes) do - { - first_name: "David", - surname: "Tau", - date_of_birth: Date.new(1999, 4, 12), - national_insurance_number: "BE562112A", - provide_mobile_number: true, - email_verified: true - } - end - [ {policy: Policies::EarlyCareerPayments, mobile_number: "07123456789", otp_code: "097543"}, {policy: Policies::StudentLoans, mobile_number: "07723190022", otp_code: "123347"} @@ -51,23 +24,16 @@ let(:mobile_number) { scenario[:mobile_number] } scenario "when making a #{scenario[:policy]} claim" do - claim = send(:"start_#{scenario[:policy].to_s.underscore}_claim") + send(:"start_#{scenario[:policy].to_s.underscore}_claim") if scenario[:policy] == Policies::EarlyCareerPayments - claim.eligibility = Policies::EarlyCareerPayments::Eligibility.new - claim.eligibility.update!(attributes_for(:early_career_payments_eligibility, :eligible)) - claim.update!(early_career_payments_personal_details_attributes) session = Journeys::AdditionalPaymentsForTeaching::Session.last elsif scenario[:policy] == Policies::StudentLoans - claim.eligibility = Policies::StudentLoans::Eligibility.new - claim.eligibility.update!(attributes_for(:student_loans_eligibility, :eligible)) - claim.update!(student_loans_personal_details_attributes) session = Journeys::TeacherStudentLoanReimbursement::Session.last end session.update!(answers: {provide_mobile_number: true}) jump_to_claim_journey_page( - claim: claim, slug: "mobile-number", journey_session: session ) diff --git a/spec/features/early_career_payments_claim_spec.rb b/spec/features/early_career_payments_claim_spec.rb index 812089b934..ac4aa18e0b 100644 --- a/spec/features/early_career_payments_claim_spec.rb +++ b/spec/features/early_career_payments_claim_spec.rb @@ -324,19 +324,8 @@ end context "Route into teaching" do - let!(:claim) do - claim = start_early_career_payments_claim - claim.eligibility.update!(attributes_for(:early_career_payments_eligibility, :eligible)) - claim - end - - let!(:lup_claim) do - lup_claim = Claim.by_policy(Policies::LevellingUpPremiumPayments).order(:created_at).last - lup_claim.eligibility.update!(attributes_for(:levelling_up_premium_payments_eligibility, :eligible)) - lup_claim - end - let!(:journey_session) do + start_early_career_payments_claim journey_session = Journeys::AdditionalPaymentsForTeaching::Session.last journey_session.answers.assign_attributes( attributes_for( @@ -351,7 +340,6 @@ scenario "when Assessment only" do jump_to_claim_journey_page( - claim: claim, slug: "qualification", journey_session: journey_session ) @@ -380,7 +368,7 @@ choose "Mathematics" click_on "Continue" - expect(claim.eligibility.reload.eligible_itt_subject).to eql "mathematics" + expect(journey_session.reload.answers.eligible_itt_subject).to eql "mathematics" # - Do you teach maths now expect(page).to have_text(I18n.t("additional_payments.forms.teaching_subject_now.questions.teaching_subject_now")) @@ -392,7 +380,7 @@ click_on "Continue" - expect(claim.eligibility.reload.itt_academic_year).to eql itt_year + expect(journey_session.reload.answers.itt_academic_year).to eql itt_year end scenario "when Overseas recognition" do @@ -400,7 +388,6 @@ journey_session.save! jump_to_claim_journey_page( - claim: claim, slug: "qualification", journey_session: ) @@ -429,7 +416,7 @@ choose "Mathematics" click_on "Continue" - expect(claim.eligibility.reload.eligible_itt_subject).to eql "mathematics" + expect(journey_session.reload.answers.eligible_itt_subject).to eql "mathematics" # - Do you teach maths now expect(page).to have_text(I18n.t("additional_payments.forms.teaching_subject_now.questions.teaching_subject_now")) @@ -439,7 +426,7 @@ expect(journey_session.reload.answers.teaching_subject_now).to eql true - expect(claim.eligibility.reload.itt_academic_year).to eql itt_year + expect(journey_session.reload.answers.itt_academic_year).to eql itt_year end end @@ -815,19 +802,8 @@ ).to_return(status: 200, body: body, headers: {}) end - let!(:claim) do - claim = start_early_career_payments_claim - claim.eligibility.update!(attributes_for(:early_career_payments_eligibility, :eligible)) - claim - end - - let!(:lup_claim) do - lup_claim = Claim.by_policy(Policies::LevellingUpPremiumPayments).order(:created_at).last - lup_claim.eligibility.update!(attributes_for(:levelling_up_premium_payments_eligibility, :eligible)) - lup_claim - end - let!(:journey_session) do + start_early_career_payments_claim session = Journeys::AdditionalPaymentsForTeaching::Session.last session.answers.assign_attributes( attributes_for( @@ -840,9 +816,13 @@ end scenario "with Ordnance Survey data" do - expect(claim.valid?(:submit)).to eq false + expect( + Journeys::AdditionalPaymentsForTeaching::ClaimSubmissionForm.new( + journey_session: journey_session + ).valid? + ).to eq false + jump_to_claim_journey_page( - claim: claim, slug: "check-your-answers-part-one", journey_session: ) diff --git a/spec/features/early_career_payments_eligible_now_reminder_set_spec.rb b/spec/features/early_career_payments_eligible_now_reminder_set_spec.rb index 9f397ffe22..cdf67bee34 100644 --- a/spec/features/early_career_payments_eligible_now_reminder_set_spec.rb +++ b/spec/features/early_career_payments_eligible_now_reminder_set_spec.rb @@ -7,7 +7,7 @@ let(:school) { create(:school, :early_career_payments_eligible, :levelling_up_premium_payments_eligible) } it "auto-sets a reminders email and name from claim params and displays the correct year" do - claim = start_early_career_payments_claim + start_early_career_payments_claim reminder_year = (academic_year + 1).start_year session = Journeys::AdditionalPaymentsForTeaching::Session.last @@ -22,11 +22,10 @@ session.save! jump_to_claim_journey_page( - claim: claim, slug: "check-your-answers", journey_session: session ) - expect(page).to have_text(claim.first_name) + expect(page).to have_text(session.answers.first_name) click_on "Accept and send" expect(page).to have_text("Set a reminder to apply next year") click_on "Set reminder" @@ -75,7 +74,7 @@ policy[:eligible_now].each do |scenario| reminder_status = (scenario[:invited_to_set_reminder] == true) ? "CAN" : "CANNOT" scenario "with cohort ITT subject #{scenario[:itt_subject]} in ITT academic year #{scenario[:itt_academic_year]} - a reminder #{reminder_status} be set" do - claim = start_early_career_payments_claim + start_early_career_payments_claim reminder_year = (academic_year + 1).start_year session = Journeys::AdditionalPaymentsForTeaching::Session.last @@ -92,7 +91,6 @@ session.save! jump_to_claim_journey_page( - claim: claim, slug: "check-your-answers", journey_session: session ) diff --git a/spec/features/ineligible_early_career_payments_in_2022_and_future_years_spec.rb b/spec/features/ineligible_early_career_payments_in_2022_and_future_years_spec.rb index 8e9a4978d4..b9e60fdda6 100644 --- a/spec/features/ineligible_early_career_payments_in_2022_and_future_years_spec.rb +++ b/spec/features/ineligible_early_career_payments_in_2022_and_future_years_spec.rb @@ -33,19 +33,12 @@ start_early_career_payments_claim - eligibility_attrs = attributes_for(:early_career_payments_eligibility, :ineligible_feature) - claim.eligibility.update!(eligibility_attrs) - journey_session.answers.assign_attributes( qualification: "postgraduate_itt" ) journey_session.save! end - let(:claim) do - Claim.by_policy(Policies::EarlyCareerPayments).order(:created_at).last - end - let(:journey_session) do Journeys::AdditionalPaymentsForTeaching::Session.last end @@ -53,7 +46,6 @@ policy[:ineligible_cohorts].each do |scenario| scenario "with cohort ITT subject #{scenario[:itt_subject]} in ITT academic year #{scenario[:itt_academic_year]}" do jump_to_claim_journey_page( - claim: claim, slug: "itt-year", journey_session: journey_session ) diff --git a/spec/features/levelling_up_premium_payments_content_change_logic_spec.rb b/spec/features/levelling_up_premium_payments_content_change_logic_spec.rb index 866d9d9eaf..8cc4671790 100644 --- a/spec/features/levelling_up_premium_payments_content_change_logic_spec.rb +++ b/spec/features/levelling_up_premium_payments_content_change_logic_spec.rb @@ -1,25 +1,19 @@ require "rails_helper" RSpec.feature "Claims with different eligibilities content change logic" do - let(:claim) { start_early_career_payments_claim } - let(:journey_session) do - Journeys::AdditionalPaymentsForTeaching::Session.last - end - before do create(:journey_configuration, :additional_payments, current_academic_year: AcademicYear.new(2022)) - claim.update!(attributes_for(:claim, :submittable)) - claim.eligibility.update!(attributes_for(:early_career_payments_eligibility, :eligible)) + start_early_career_payments_claim + journey_session = Journeys::AdditionalPaymentsForTeaching::Session.last journey_session.answers.assign_attributes(qualification: "postgraduate_itt") journey_session.save! - end - - it "shows the correct subjects for LUP-only and ECP claims" do jump_to_claim_journey_page( - claim: claim, slug: "itt-year", journey_session: journey_session ) + end + + it "shows the correct subjects for LUP-only and ECP claims" do choose "2017 to 2018" click_on "Continue" expected_subjects = ["Chemistry", "Computing", "Mathematics", "Physics", "None of the above"] diff --git a/spec/features/one_time_password_spec.rb b/spec/features/one_time_password_spec.rb index 6547c625b5..b92e3f07f0 100644 --- a/spec/features/one_time_password_spec.rb +++ b/spec/features/one_time_password_spec.rb @@ -3,13 +3,10 @@ RSpec.feature "Given a one time password" do let!(:drift) { OneTimePassword::Base::DRIFT } - let(:claim) { start_early_career_payments_claim } - before do create(:journey_configuration, :additional_payments) - claim.eligibility.update!(attributes_for(:early_career_payments_eligibility, :eligible)) + start_early_career_payments_claim jump_to_claim_journey_page( - claim: claim, slug: "email-address", journey_session: Journeys::AdditionalPaymentsForTeaching::Session.last ) diff --git a/spec/features/reminders_spec.rb b/spec/features/reminders_spec.rb index dd01a1e4a6..6107c2258d 100644 --- a/spec/features/reminders_spec.rb +++ b/spec/features/reminders_spec.rb @@ -35,10 +35,9 @@ journey_session.save! expect(claim.policy).to eq Policies::EarlyCareerPayments - expect(claim.eligibility.reload.eligible_itt_subject).to eq args[:subject] + expect(journey_session.reload.answers.eligible_itt_subject).to eq args[:subject] jump_to_claim_journey_page( - claim:, slug: "itt-year", journey_session: journey_session ) @@ -103,31 +102,23 @@ claim = start_early_career_payments_claim journey_session = Journeys::AdditionalPaymentsForTeaching::Session.last - claim.eligibility.update!( - attributes_for( - :early_career_payments_eligibility, - :eligible, - eligible_itt_subject: args[:subject] - ) - ) - journey_session.answers.assign_attributes( attributes_for( :additional_payments_answers, + :submittable, qualification: "postgraduate_itt", current_school_id: school.id, nqt_in_academic_year_after_itt: true, - induction_completed: true + induction_completed: true, + eligible_itt_subject: args[:subject] ) ) journey_session.save! - expect(claim.policy).to eq Policies::EarlyCareerPayments - expect(claim.eligibility.reload.eligible_itt_subject).to eq args[:subject] + expect(journey_session.reload.answers.eligible_itt_subject).to eq args[:subject] jump_to_claim_journey_page( - claim:, slug: "itt-year", journey_session: journey_session ) @@ -150,7 +141,11 @@ expect(page).to have_text(I18n.t("additional_payments.check_your_answers.part_one.confirmation_notice")) expect(journey_session.reload.answers.itt_academic_year).to eq args[:academic_year] - expect(claim.errors.messages).to be_empty + expect( + Journeys::AdditionalPaymentsForTeaching::ClaimSubmissionForm.new( + journey_session: journey_session + ).tap(&:validate).errors.messages + ).to be_empty click_on "Continue" diff --git a/spec/features/subject_teaching_question_spec.rb b/spec/features/subject_teaching_question_spec.rb index 31d120ab02..d887a59c46 100644 --- a/spec/features/subject_teaching_question_spec.rb +++ b/spec/features/subject_teaching_question_spec.rb @@ -1,14 +1,12 @@ require "rails_helper" RSpec.feature "Resetting dependant attributes when the claim is ineligible" do - let(:claim) { start_early_career_payments_claim } let(:journey_session) { Journeys::AdditionalPaymentsForTeaching::Session.last } before { create(:journey_configuration, :additional_payments, current_academic_year: AcademicYear.new(2022)) } before do - claim.update!(attributes_for(:claim, :submittable)) - claim.eligibility.update!(attributes_for(:early_career_payments_eligibility, :eligible, :eligible_school_ecp_and_lup)) + start_early_career_payments_claim journey_session.answers.assign_attributes( attributes_for( :additional_payments_answers, @@ -23,7 +21,6 @@ context "when ECP and LUP eligible" do it "has the correct subjects" do jump_to_claim_journey_page( - claim: claim, slug: "nqt-in-academic-year-after-itt", journey_session: journey_session ) @@ -31,7 +28,6 @@ click_on "Continue" jump_to_claim_journey_page( - claim: claim, slug: "itt-year", journey_session: journey_session ) @@ -39,7 +35,6 @@ click_on "Continue" jump_to_claim_journey_page( - claim: claim, slug: "eligible-itt-subject", journey_session: journey_session ) @@ -47,7 +42,6 @@ click_on "Continue" jump_to_claim_journey_page( - claim: claim, slug: "teaching-subject-now", journey_session: journey_session ) @@ -61,7 +55,6 @@ context "when eligible only for ECP" do it "has the correct subjects" do jump_to_claim_journey_page( - claim: claim, slug: "nqt-in-academic-year-after-itt", journey_session: journey_session ) @@ -69,7 +62,6 @@ click_on "Continue" jump_to_claim_journey_page( - claim: claim, slug: "itt-year", journey_session: journey_session ) @@ -77,7 +69,6 @@ click_on "Continue" jump_to_claim_journey_page( - claim: claim, slug: "eligible-itt-subject", journey_session: journey_session ) @@ -85,7 +76,6 @@ click_on "Continue" jump_to_claim_journey_page( - claim: claim, slug: "teaching-subject-now", journey_session: journey_session ) @@ -95,7 +85,6 @@ context "when eligible only for LUP" do before do - claim.eligibility.update!(attributes_for(:early_career_payments_eligibility, :ineligible)) journey_session.answers.assign_attributes( attributes_for( :additional_payments_answers, @@ -108,7 +97,6 @@ it "has the correct subjects" do jump_to_claim_journey_page( - claim: claim, slug: "teaching-subject-now", journey_session: journey_session ) diff --git a/spec/features/validating_user_contact_details_spec.rb b/spec/features/validating_user_contact_details_spec.rb index a1d453c51b..571405cf86 100644 --- a/spec/features/validating_user_contact_details_spec.rb +++ b/spec/features/validating_user_contact_details_spec.rb @@ -4,9 +4,7 @@ before { create(:journey_configuration, :additional_payments) } it "redirects to 'email-address' if 'Change email address' is clicked on the One Time Password page" do - claim = start_early_career_payments_claim - claim.update!(attributes_for(:claim, :submittable)) - claim.eligibility.update!(attributes_for(:early_career_payments_eligibility, :eligible)) + start_early_career_payments_claim journey_session = Journeys::AdditionalPaymentsForTeaching::Session.last journey_session.answers.assign_attributes( @@ -27,7 +25,6 @@ ) jump_to_claim_journey_page( - claim: claim, slug: "email-verification", journey_session: journey_session ) diff --git a/spec/forms/form_spec.rb b/spec/forms/form_spec.rb index 12f3344882..24a286919d 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, journey_session) + def initialize(journey_session) # NOOP end end 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 f53fe9acc1..6b8f6362be 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,22 +1,7 @@ require "rails_helper" RSpec.describe Journeys::AdditionalPaymentsForTeaching::SlugSequence do - 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) } - - let(:claim) do - create( - :claim, - :skipped_tid, - policy: Policies::EarlyCareerPayments, - academic_year: AcademicYear.new(2021), - eligibility: eligibility - ) - end - 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]) } + subject(:slug_sequence) { described_class.new(journey_session) } let(:journey_session) do create(:additional_payments_session, answers: answers) end @@ -231,13 +216,13 @@ end it "includes teacher reference number slug if teacher reference number is nil" do - claim.teacher_reference_number = nil + journey_session.answers.teacher_reference_number = nil expect(slug_sequence.slugs).to include("teacher-reference-number") end it "includes teacher reference number slug if teacher reference number is not nil" do - claim.teacher_reference_number = "1234567" + journey_session.answers.teacher_reference_number = "1234567" expect(slug_sequence.slugs).to include("teacher-reference-number") end @@ -370,20 +355,9 @@ create(:journey_configuration, :additional_payments) end - let(:current_school) { create(:school, :combined_journey_eligibile_for_all) } - let(:ecp_claim) { create(:claim, policy: Policies::EarlyCareerPayments, eligibility_trait: ecp_eligibility) } - let(:lup_claim) { create(:claim, policy: Policies::LevellingUpPremiumPayments, eligibility_trait: lup_eligibility) } - - let(:current_claim) { CurrentClaim.new(claims: [ecp_claim, lup_claim]) } - - subject { described_class.new(current_claim, journey_session).slugs } + subject { described_class.new(journey_session).slugs } context "current claim is :eligible_now" do - let(:current_school) { create(:school, :combined_journey_eligibile_for_all) } - - let(:ecp_claim) { create(:claim, policy: Policies::EarlyCareerPayments, eligibility_trait: ecp_eligibility, eligibility_attributes: {current_school: current_school}) } - let(:lup_claim) { create(:claim, policy: Policies::LevellingUpPremiumPayments, eligibility_trait: lup_eligibility, eligibility_attributes: {current_school: current_school}) } - let(:journey_session) do build( :additional_payments_session, @@ -394,17 +368,11 @@ ) end - let(:ecp_eligibility) { :eligible_later } - let(:lup_eligibility) { :eligible_now } - it { is_expected.to include("eligibility-confirmed") } it { is_expected.not_to include("eligible-later", "ineligible") } end context "current claim is :eligible_later" do - let(:ecp_eligibility) { :eligible_later } - let(:lup_eligibility) { :ineligible } - let(:journey_session) do build( :additional_payments_session, @@ -420,9 +388,6 @@ end context "current claim is :ineligible" do - let(:ecp_eligibility) { :ineligible } - let(:lup_eligibility) { :ineligible } - let(:journey_session) do build( :additional_payments_session, diff --git a/spec/models/journeys/additional_payments_for_teaching_spec.rb b/spec/models/journeys/additional_payments_for_teaching_spec.rb index 44de680e8f..5ccadf6064 100644 --- a/spec/models/journeys/additional_payments_for_teaching_spec.rb +++ b/spec/models/journeys/additional_payments_for_teaching_spec.rb @@ -36,15 +36,10 @@ describe ".page_sequence_for_claim" do let(:completed_slugs) { [:test] } let(:current_slug) { [:test2] } - let(:current_claim) do - claims = Journeys::AdditionalPaymentsForTeaching::POLICIES.map { |policy| create(:claim, policy: policy) } - CurrentClaim.new(claims: claims) - end let(:journey_session) { build(:additional_payments_session) } subject(:page_sequence) do described_class.page_sequence_for_claim( - current_claim, journey_session, completed_slugs, current_slug @@ -54,14 +49,13 @@ it { is_expected.to be_a(Journeys::PageSequence) } it "populates the page sequence attributes" do - expect(page_sequence.claim).to eq(current_claim) expect(page_sequence.current_slug).to eq(current_slug) expect(page_sequence.completed_slugs).to eq(completed_slugs) end it "creates a slug sequence" do expect(Journeys::AdditionalPaymentsForTeaching::SlugSequence).to( - receive(:new).with(current_claim, journey_session) + receive(:new).with(journey_session) ) page_sequence end diff --git a/spec/models/journeys/page_sequence_spec.rb b/spec/models/journeys/page_sequence_spec.rb index 495bdb1335..1cd27fd1b1 100644 --- a/spec/models/journeys/page_sequence_spec.rb +++ b/spec/models/journeys/page_sequence_spec.rb @@ -4,14 +4,12 @@ RSpec.describe Journeys::PageSequence do let(:claim) { build(:claim) } - let(:current_claim) { CurrentClaim.new(claims: [claim]) } let(:slug_sequence) { OpenStruct.new(slugs: ["first-slug", "second-slug", "third-slug"]) } let(:completed_slugs) { [] } let(:journey_session) { create(:student_loans_session) } subject(:page_sequence) do described_class.new( - current_claim, slug_sequence, completed_slugs, current_slug, @@ -59,7 +57,6 @@ end context "when the claim is in a submittable state (i.e. all questions have been answered)" do - let(:claim) { build(:claim, :submittable) } let(:current_slug) { "third-slug" } let(:completed_slugs) { ["first-slug", "second-slug", "third-slug"] } let(:journey_session) do @@ -72,7 +69,6 @@ it { is_expected.to eq("check-your-answers") } context "when student-loan-amount is in the sequence and the current slug is personal-details" do - let(:claim) { build(:claim, :submittable) } let(:slug_sequence) { OpenStruct.new(slugs: ["personal-details", "student-loan-amount"]) } let(:current_slug) { "personal-details" } let(:completed_slugs) { ["personal-details", "student-loan-amount"] } @@ -87,7 +83,6 @@ {policy: Policies::StudentLoans, next_slug: "date-of-birth", slug_sequence: OpenStruct.new(slugs: ["postcode-search", "select-home-address", "address", "date-of-birth"])} ].each do |scenario| context "#{scenario[:policy]} claim" do - let(:claim) { build(:claim, policy: scenario[:policy]) } let(:journey) { Journeys.for_policy(scenario[:policy]) } let(:journey_session) do build( @@ -101,6 +96,10 @@ let(:current_slug) { "select-home-address" } let(:completed_slugs) { ["postcode-search", "select-home-address"] } + before do + create(:journey_configuration, journey::I18N_NAMESPACE) + end + it { is_expected.to eq(scenario[:next_slug]) } 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 90143c7f09..a7ee49df7d 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,10 @@ require "rails_helper" RSpec.describe Journeys::TeacherStudentLoanReimbursement::SlugSequence do - subject(:slug_sequence) { described_class.new(current_claim, journey_session) } + before { create(:journey_configuration, :student_loans) } + + subject(:slug_sequence) { described_class.new(journey_session) } - let(:eligibility) { create(:student_loans_eligibility, :eligible) } - let(:claim) { build(:claim, eligibility:) } - let(:current_claim) { CurrentClaim.new(claims: [claim]) } let(:journey_session) do build( :student_loans_session, @@ -24,7 +23,11 @@ describe "The sequence as defined by #slugs" do it "excludes the “ineligible” slug if the claim is not actually ineligible" do - expect(claim.eligibility).not_to be_ineligible + expect( + Journeys::TeacherStudentLoanReimbursement::EligibilityChecker.new( + journey_session: journey_session + ) + ).not_to be_ineligible expect(slug_sequence.slugs).not_to include("ineligible") end @@ -86,7 +89,11 @@ end context "when Teacher ID is disabled on the policy configuration" do - before { create(:journey_configuration, :student_loans, teacher_id_enabled: false) } + before do + Journeys::TeacherStudentLoanReimbursement.configuration.update!( + teacher_id_enabled: false + ) + end it "removes the Teacher ID-dependant slugs" do slugs = %w[sign-in-or-continue reset-claim qualification-details select-email select-mobile] diff --git a/spec/models/journeys/teacher_student_loan_reimbursement_spec.rb b/spec/models/journeys/teacher_student_loan_reimbursement_spec.rb index 45809720d6..3afa336fc1 100644 --- a/spec/models/journeys/teacher_student_loan_reimbursement_spec.rb +++ b/spec/models/journeys/teacher_student_loan_reimbursement_spec.rb @@ -37,11 +37,9 @@ let(:completed_slugs) { [:test] } let(:current_slug) { [:test2] } let(:journey_session) { build(:student_loans_session) } - let(:claim) { double } subject(:page_sequence) do described_class.page_sequence_for_claim( - claim, journey_session, completed_slugs, current_slug @@ -51,14 +49,13 @@ it { is_expected.to be_a(Journeys::PageSequence) } it "populates the page sequence attributes" do - expect(page_sequence.claim).to eq(claim) expect(page_sequence.current_slug).to eq(current_slug) expect(page_sequence.completed_slugs).to eq(completed_slugs) end it "creates a slug sequence" do expect(Journeys::TeacherStudentLoanReimbursement::SlugSequence).to( - receive(:new).with(claim, journey_session) + receive(:new).with(journey_session) ) page_sequence diff --git a/spec/requests/claims_spec.rb b/spec/requests/claims_spec.rb index 1c7846799e..67910467e3 100644 --- a/spec/requests/claims_spec.rb +++ b/spec/requests/claims_spec.rb @@ -75,7 +75,7 @@ def check_slug_redirection before { create(:journey_configuration, :student_loans) } context "when a claim is already in progress" do - let(:in_progress_claim) { Claim.by_policy(Policies::StudentLoans).order(:created_at).last } + let(:journey_session) { Journeys::TeacherStudentLoanReimbursement::Session.order(:created_at).last } before { start_student_loans_claim } @@ -91,7 +91,7 @@ def check_slug_redirection end context "when the user has completed the journey in the correct slug sequence" do - before { set_slug_sequence_in_session(in_progress_claim, "claim-school") } + before { set_slug_sequence_in_session(journey_session, "claim-school") } it "renders the requested page in the sequence" do get claim_path(Journeys::TeacherStudentLoanReimbursement::ROUTING_NAME, "claim-school") @@ -176,15 +176,13 @@ def check_slug_redirection before { create(:journey_configuration, :student_loans) } context "when a claim is already in progress" do - let(:in_progress_claim) { Claim.by_policy(Policies::StudentLoans).order(:created_at).last } - let(:journey_session) do Journeys::TeacherStudentLoanReimbursement::Session.order(:created_at).last end before { start_student_loans_claim - set_slug_sequence_in_session(in_progress_claim, "qts-year") + set_slug_sequence_in_session(journey_session, "qts-year") } it "updates the claim with the submitted form data" do @@ -213,7 +211,7 @@ def check_slug_redirection let(:request) { put claim_path(Journeys::TeacherStudentLoanReimbursement::ROUTING_NAME, "personal-details"), params: } before do - set_slug_sequence_in_session(in_progress_claim, "personal-details") + set_slug_sequence_in_session(journey_session, "personal-details") end it "updates the student loan details" do @@ -230,15 +228,15 @@ def check_slug_redirection journey_session.answers.assign_attributes(logged_in_with_tid: true) journey_session.save! end - set_slug_sequence_in_session(in_progress_claim, "information-provided") + set_slug_sequence_in_session(journey_session, "information-provided") end context "within the non-TID journey" do let(:tid_journey?) { false } it "does not update the student loan details" do - expect { request }.to not_change { in_progress_claim.reload.has_student_loan } - .and not_change { in_progress_claim.student_loan_plan } + expect { request }.to not_change { journey_session.reload.answers.has_student_loan } + .and not_change { journey_session.reload.answers.student_loan_plan } end end @@ -309,14 +307,15 @@ def check_slug_redirection end context "when the user has completed the journey in the correct slug sequence" do - before { set_slug_sequence_in_session(in_progress_claim, "provide-mobile-number") } + before { set_slug_sequence_in_session(journey_session, "provide-mobile-number") } it "resets dependent claim attributes when appropriate" do - in_progress_claim.update!(provide_mobile_number: false, mobile_number: nil) + journey_session.answers.assign_attributes(provide_mobile_number: false, mobile_number: nil) + journey_session.save! put claim_path(Journeys::TeacherStudentLoanReimbursement::ROUTING_NAME, "provide-mobile-number"), params: {claim: {provide_mobile_number: true}} expect(response).to redirect_to(claim_path(Journeys::TeacherStudentLoanReimbursement::ROUTING_NAME, "mobile-number")) - expect(in_progress_claim.reload.student_loan_plan).to be_nil + expect(journey_session.reload.answers.student_loan_plan).to be_nil end end @@ -326,7 +325,7 @@ def check_slug_redirection mostly_performed_leadership_duties: false ) journey_session.save! - set_slug_sequence_in_session(in_progress_claim, "leadership-position") + set_slug_sequence_in_session(journey_session, "leadership-position") put claim_path(Journeys::TeacherStudentLoanReimbursement::ROUTING_NAME, "leadership-position"), params: {claim: {had_leadership_position: false}} expect(response).to redirect_to(claim_path(Journeys::TeacherStudentLoanReimbursement::ROUTING_NAME, "eligibility-confirmed")) @@ -338,7 +337,7 @@ def check_slug_redirection context "having searched for a school but not selected a school from the results on the claim-school page" do let!(:school) { create(:school) } - before { set_slug_sequence_in_session(in_progress_claim, "claim-school") } + before { set_slug_sequence_in_session(journey_session, "claim-school") } it "re-renders the school search results with an error message" do put claim_path(Journeys::TeacherStudentLoanReimbursement::ROUTING_NAME, "claim-school"), params: {school_search: school.name, claim: {claim_school_id: ""}} @@ -354,7 +353,7 @@ def check_slug_redirection let(:ineligible_school) { create(:school, :student_loans_ineligible) } it "redirects to the “ineligible” page" do - set_slug_sequence_in_session(in_progress_claim, "claim-school") + set_slug_sequence_in_session(journey_session, "claim-school") put claim_path(Journeys::TeacherStudentLoanReimbursement::ROUTING_NAME, "claim-school"), params: {claim: {claim_school_id: ineligible_school.to_param}} expect(response).to redirect_to(claim_path(Journeys::TeacherStudentLoanReimbursement::ROUTING_NAME, "ineligible")) diff --git a/spec/requests/timeout_spec.rb b/spec/requests/timeout_spec.rb index 61e137fc82..1795ba14b6 100644 --- a/spec/requests/timeout_spec.rb +++ b/spec/requests/timeout_spec.rb @@ -2,7 +2,10 @@ RSpec.describe "Claim session timing out", type: :request do let(:timeout_length_in_minutes) { BasePublicController::CLAIM_TIMEOUT_LENGTH_IN_MINUTES } - let(:current_claim) { CurrentClaim.new(claims: [Claim.by_policy(Policies::StudentLoans).order(:created_at).last]) } + let(:journey_session) do + Journeys::TeacherStudentLoanReimbursement::Session.last + end + before { create(:journey_configuration, :student_loans) } context "no actions performed for more than the timeout period" do @@ -13,7 +16,9 @@ let(:after_expiry) { timeout_length_in_minutes.minutes + 1.second } it "clears the session and redirects to the timeout page" do - expect(session[:claim_id]).to eql current_claim.claim_ids + expect( + session[:"student-loans_journeys_session_id"] + ).to eq journey_session.id travel after_expiry do put claim_path(Journeys::TeacherStudentLoanReimbursement::ROUTING_NAME, "qts-year"), params: {claim: {qts_award_year: "on_or_after_cut_off_date"}} @@ -27,7 +32,7 @@ context "no action performed just within the timeout period" do before do start_student_loans_claim - set_slug_sequence_in_session(current_claim, "qts-year") + set_slug_sequence_in_session(journey_session, "qts-year") end let(:before_expiry) { timeout_length_in_minutes.minutes - 2.seconds } diff --git a/spec/support/eligible_later_shared_examples.rb b/spec/support/eligible_later_shared_examples.rb index c08f4965e1..9064de362b 100644 --- a/spec/support/eligible_later_shared_examples.rb +++ b/spec/support/eligible_later_shared_examples.rb @@ -30,7 +30,6 @@ journey_session.save! jump_to_claim_journey_page( - claim: claim, slug: "check-your-answers-part-one", journey_session: journey_session ) diff --git a/spec/support/feature_helpers.rb b/spec/support/feature_helpers.rb index 1b1fb0e651..9e860e318b 100644 --- a/spec/support/feature_helpers.rb +++ b/spec/support/feature_helpers.rb @@ -121,15 +121,15 @@ def skip_tid # is to spoof the session's record of visited pages in the journey. # # TODO: refactor all old feature specs which use this method - def jump_to_claim_journey_page(claim:, journey_session:, slug:) - set_slug_sequence_in_session(claim:, journey_session:, slug:) - visit claim_path(Journeys.for_policy(claim.policy)::ROUTING_NAME, slug) + def jump_to_claim_journey_page(journey_session:, slug:) + set_slug_sequence_in_session(journey_session:, slug:) + journey = Journeys.for_routing_name(journey_session.journey) + visit claim_path(journey::ROUTING_NAME, slug) end - def set_slug_sequence_in_session(claim:, journey_session:, slug:) - current_claim = CurrentClaim.new(claims: [claim]) - journey = Journeys.for_policy(claim.policy) - slug_sequence = journey.slug_sequence.new(current_claim, journey_session).slugs + def set_slug_sequence_in_session(journey_session:, slug:) + journey = Journeys.for_routing_name(journey_session.journey) + slug_sequence = journey.slug_sequence.new(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 d67e3f5690..a0ae2342d8 100644 --- a/spec/support/request_helpers.rb +++ b/spec/support/request_helpers.rb @@ -27,11 +27,9 @@ def sign_in_to_admin_with_role(*) follow_redirect! end - def set_slug_sequence_in_session(claim, slug) - current_claim = CurrentClaim.new(claims: [claim]) - journey = Journeys.for_policy(claim.policy) - journey_session = build(:"#{journey::I18N_NAMESPACE}_session") - slug_sequence = journey.slug_sequence.new(current_claim, journey_session).slugs + def set_slug_sequence_in_session(journey_session, slug) + journey = Journeys.for_routing_name(journey_session.journey) + slug_sequence = journey.slug_sequence.new(journey_session).slugs slug_index = slug_sequence.index(slug) visited_slugs = slug_sequence.slice(0, slug_index)