Skip to content

Commit

Permalink
AP-5701: Update proceeding_types controller
Browse files Browse the repository at this point in the history
If no proceedings are found, redirect to the has_other_proceedings page

This should avoid a user pushing the back button and arriving at a page that
cannot be displayed because there are no proceedings to choose from
  • Loading branch information
colinbruce committed Jan 31, 2025
1 parent 7e11f4b commit 4a4330f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/controllers/providers/proceedings_types_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ class ProceedingsTypesController < ProviderBaseController
def index
proceeding_types
excluded_codes
rescue LegalFramework::ProceedingTypes::All::NoMatchingProceedingsFoundError
redirect_to providers_legal_aid_application_has_other_proceedings_path(legal_aid_application)
end

# POST /provider/applications/:legal_aid_application_id/proceedings_types
Expand Down
11 changes: 11 additions & 0 deletions spec/requests/providers/proceedings_types_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@
expect(response.body).not_to include("govuk-form-group--error")
end

context "when there are no available proceedings to show" do
before do
allow(LegalFramework::ProceedingTypes::All).to receive(:call).and_raise(LegalFramework::ProceedingTypes::All::NoMatchingProceedingsFoundError)
end

it "redirects to the has_other_proceedings page" do
get_request
expect(response).to redirect_to providers_legal_aid_application_has_other_proceedings_path(legal_aid_application)
end
end

describe "back link" do
context "when the applicant's address used address lookup service", :vcr do
let(:legal_aid_application) { create(:legal_aid_application, :with_applicant_and_address_lookup) }
Expand Down

0 comments on commit 4a4330f

Please sign in to comment.