diff --git a/app/controllers/concerns/part_of_claim_journey.rb b/app/controllers/concerns/part_of_claim_journey.rb index f529be480f..055ff3caec 100644 --- a/app/controllers/concerns/part_of_claim_journey.rb +++ b/app/controllers/concerns/part_of_claim_journey.rb @@ -32,7 +32,7 @@ def send_to_start? def submitted_claim return unless session[:submitted_claim_id] - Claim.find(session[:submitted_claim_id]) + Claim.by_policies_for_journey(journey).find_by(id: session[:submitted_claim_id]) end def set_cache_headers diff --git a/app/controllers/journeys/additional_payments_for_teaching/reminders_controller.rb b/app/controllers/journeys/additional_payments_for_teaching/reminders_controller.rb index bd60a7a670..8c75859477 100644 --- a/app/controllers/journeys/additional_payments_for_teaching/reminders_controller.rb +++ b/app/controllers/journeys/additional_payments_for_teaching/reminders_controller.rb @@ -66,7 +66,7 @@ def build_reminder_from_claim ) end - # Remidners can be set for inprogress and submitted claims + # Reminders can be set for in progress and submitted claims # We can tell if we're setting a reminder for a submitted claim as the # journey session will be nil given that we clear it on claim submission. def model_for_reminder_attributes diff --git a/app/models/claim.rb b/app/models/claim.rb index 9006adb23c..298219227a 100644 --- a/app/models/claim.rb +++ b/app/models/claim.rb @@ -183,6 +183,7 @@ class Claim < ApplicationRecord scope :passed_decision_deadline, -> { awaiting_decision.where("submitted_at < ?", DECISION_DEADLINE.ago) } scope :by_policy, ->(policy) { where(eligibility_type: policy::Eligibility.to_s) } scope :by_policies, ->(policies) { where(eligibility_type: policies.map { |p| p::Eligibility.to_s }) } + scope :by_policies_for_journey, ->(journey) { by_policies(journey::POLICIES) } scope :by_academic_year, ->(academic_year) { where(academic_year: academic_year) } scope :assigned_to_team_member, ->(service_operator_id) { where(assigned_to_id: service_operator_id) } scope :by_claims_team_member, ->(service_operator_id, status) do diff --git a/spec/features/further_education_payments/provider/provider_verifying_claims_spec.rb b/spec/features/further_education_payments/provider/provider_verifying_claims_spec.rb index 32f325efc5..47f32f94c5 100644 --- a/spec/features/further_education_payments/provider/provider_verifying_claims_spec.rb +++ b/spec/features/further_education_payments/provider/provider_verifying_claims_spec.rb @@ -264,7 +264,7 @@ ) end - scenario "provider visits a claim with an inprogress session" do + scenario "provider visits a claim with an in progress session" do fe_provider = create(:school, :further_education, name: "Springfield A and M") claim_1 = create( diff --git a/spec/requests/submissions_spec.rb b/spec/requests/submissions_spec.rb index f6a52124b8..848c807df0 100644 --- a/spec/requests/submissions_spec.rb +++ b/spec/requests/submissions_spec.rb @@ -112,5 +112,17 @@ expect(response).to redirect_to(Journeys::TeacherStudentLoanReimbursement.start_page_url) end end + + context "when the claim with submitted_claim_id in the session is a policy that is not for this journey" do + before do + create(:journey_configuration, :additional_payments) + set_session_data(submitted_claim_id: create(:claim, :submitted).id) + end + + it "redirects to the start page of the journey in the url path ignoring the submitted_claim_id" do + get claim_confirmation_path(Journeys::AdditionalPaymentsForTeaching::ROUTING_NAME) + expect(response).to redirect_to(Journeys::AdditionalPaymentsForTeaching.start_page_url) + end + end end end