Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CAPT-1860 check submitted claim is a policy for current journey #3315

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/concerns/part_of_claim_journey.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions app/models/claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
12 changes: 12 additions & 0 deletions spec/requests/submissions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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