From fcccfbc534cb2544876705a471993c29b738a59d Mon Sep 17 00:00:00 2001 From: Laurence de Bruxelles Date: Wed, 20 May 2026 16:12:04 +0300 Subject: [PATCH 1/3] Move controller spec to controllers folder Controller specs conventionally live in `spec/controllers` [[1]]. [1]: https://rspec.info/features/8-0/rspec-rails/controller-specs/ --- spec/{controller => controllers}/web_controller_spec.rb | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename spec/{controller => controllers}/web_controller_spec.rb (100%) diff --git a/spec/controller/web_controller_spec.rb b/spec/controllers/web_controller_spec.rb similarity index 100% rename from spec/controller/web_controller_spec.rb rename to spec/controllers/web_controller_spec.rb From cb4e222052aaff280bfe5d6593d0c0ce22280a6a Mon Sep 17 00:00:00 2001 From: Laurence de Bruxelles Date: Wed, 20 May 2026 16:10:31 +0300 Subject: [PATCH 2/3] Rename unprocessable_entity to unprocessable_content When the 422 status was initially proposed in [RFC4918](https://datatracker.ietf.org/doc/html/rfc4918) (2007), it was called 'Unprocessable entity'. When it became a standard in [RFC9110](https://datatracker.ietf.org/doc/html/rfc9110) (2022), it was renamed 'Unprocessable content'. Rack now supports it as `:unprocessable_content` and has deprecated `:unprocessable_entity`. This commit updates it to use the new name. Co-authored-by: David Biddle --- app/controllers/account/contact_for_research_controller.rb | 2 +- spec/controllers/forms/copy_of_answers_controller_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/account/contact_for_research_controller.rb b/app/controllers/account/contact_for_research_controller.rb index 08baa2af98..7ca706bb49 100644 --- a/app/controllers/account/contact_for_research_controller.rb +++ b/app/controllers/account/contact_for_research_controller.rb @@ -14,7 +14,7 @@ def update if @contact_for_research_input.submit redirect_to next_path else - render :edit, status: :unprocessable_entity + render :edit, status: :unprocessable_content end end diff --git a/spec/controllers/forms/copy_of_answers_controller_spec.rb b/spec/controllers/forms/copy_of_answers_controller_spec.rb index 6dcb624139..eaddc7b9af 100644 --- a/spec/controllers/forms/copy_of_answers_controller_spec.rb +++ b/spec/controllers/forms/copy_of_answers_controller_spec.rb @@ -94,9 +94,9 @@ context "when the send_copy_of_answers value is invalid" do let(:send_copy_of_answers) { "invalid_value" } - it "renders the new template with unprocessable entity status" do + it "renders the new template with unprocessable content status" do post(copy_of_answers_create_path(form_id: form.id), params:) - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response).to have_rendered :new expect(response.body).to include("Sorry, there was a problem. Please try again.") end From de647bc81ed8488354587dce145e458ecdc0bee5 Mon Sep 17 00:00:00 2001 From: Laurence de Bruxelles Date: Thu, 21 May 2026 09:15:50 +0300 Subject: [PATCH 3/3] Remove exact option from selectors in specs The :exact option only has an effect on queries using the XPath#is method, and just raises a warning otherwise. I've verified that these tests do fail if the text is not in the expected plural form. As the :exact option not having any effect on this test, we don't need it, and can remove it. --- spec/components/page_list_component/view_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/components/page_list_component/view_spec.rb b/spec/components/page_list_component/view_spec.rb index c82407519d..2d0be7eba5 100644 --- a/spec/components/page_list_component/view_spec.rb +++ b/spec/components/page_list_component/view_spec.rb @@ -196,7 +196,7 @@ end it "renders the route summary list key as a singular route" do - expect(page).to have_css("dt.govuk-summary-list__key", text: /Question #{first_page.position}’s route$/, exact: true) + expect(page).to have_css("dt.govuk-summary-list__key", text: /Question #{first_page.position}’s route$/) end it "renders the condition description" do @@ -221,7 +221,7 @@ end it "renders the route summary list key as plural routes" do - expect(page).to have_css("dt.govuk-summary-list__key", text: /Question #{first_page.position}’s routes$/, exact: true) + expect(page).to have_css("dt.govuk-summary-list__key", text: /Question #{first_page.position}’s routes$/) end it "renders the condition description" do