From 84c294ce85b0c6c1bc7d592c0ce67f255f5b77a3 Mon Sep 17 00:00:00 2001 From: ColinBruce Date: Fri, 31 Jan 2025 12:32:20 +0000 Subject: [PATCH] AP-5701: Update proceeding_types controller 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 --- .../providers/proceedings_types_controller.rb | 2 ++ .../providers/proceedings_types_controller_spec.rb | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/app/controllers/providers/proceedings_types_controller.rb b/app/controllers/providers/proceedings_types_controller.rb index 733f8f8b591..16c9e80753e 100644 --- a/app/controllers/providers/proceedings_types_controller.rb +++ b/app/controllers/providers/proceedings_types_controller.rb @@ -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 diff --git a/spec/requests/providers/proceedings_types_controller_spec.rb b/spec/requests/providers/proceedings_types_controller_spec.rb index 94c282a4875..c7d657141ae 100644 --- a/spec/requests/providers/proceedings_types_controller_spec.rb +++ b/spec/requests/providers/proceedings_types_controller_spec.rb @@ -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) }