Skip to content

Commit 1fcb34e

Browse files
committed
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.
1 parent c193d87 commit 1fcb34e

File tree

8 files changed

+14
-14
lines changed

8 files changed

+14
-14
lines changed

app/controllers/forms/check_your_answers_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def submit_answers
2626
unless email_confirmation_input.valid?
2727
setup_check_your_answers
2828

29-
return render template: "forms/check_your_answers/show", locals: { email_confirmation_input: }, status: :unprocessable_entity
29+
return render template: "forms/check_your_answers/show", locals: { email_confirmation_input: }, status: :unprocessable_content
3030
end
3131

3232
return redirect_to error_repeat_submission_path(current_form.id) if current_context.form_submitted?

app/controllers/forms/page_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def save
3030
redirect_post_save
3131
else
3232
setup_instance_vars_for_view
33-
render :show, status: :unprocessable_entity
33+
render :show, status: :unprocessable_content
3434
end
3535
end
3636

@@ -152,7 +152,7 @@ def check_goto_page_routing_error
152152
error_name: first_goto_error_name,
153153
link_url: admin_edit_condition_url(@step.form_id, routes_page_id),
154154
question_number: routes_page.page_number,
155-
}, status: :unprocessable_entity
155+
}, status: :unprocessable_content
156156
end
157157

158158
def admin_edit_condition_url(form_id, page_id)

app/controllers/forms/remove_answer_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def delete
88
@remove_input = RemoveInput.new(remove_input_params)
99

1010
if @remove_input.invalid?
11-
return render :show, status: :unprocessable_entity
11+
return render :show, status: :unprocessable_content
1212
end
1313

1414
if @remove_input.remove?

app/controllers/forms/remove_file_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def destroy
1212

1313
if @remove_input.invalid?
1414
setup_urls
15-
return render :show, status: :unprocessable_entity
15+
return render :show, status: :unprocessable_content
1616
end
1717

1818
if @remove_input.remove?

spec/requests/forms/check_your_answers_controller_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@
558558
end
559559

560560
it "return 422 error code" do
561-
expect(response).to have_http_status(:unprocessable_entity)
561+
expect(response).to have_http_status(:unprocessable_content)
562562
end
563563

564564
it "renders the check your answers page" do
@@ -584,7 +584,7 @@
584584
end
585585

586586
it "return 422 error code" do
587-
expect(response).to have_http_status(:unprocessable_entity)
587+
expect(response).to have_http_status(:unprocessable_content)
588588
end
589589

590590
it "renders the check your answers page" do

spec/requests/forms/page_controller_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@
284284

285285
it "returns a 422 response" do
286286
get form_page_path(mode:, form_id: 2, form_slug: form_data.form_slug, page_slug: 1)
287-
expect(response).to have_http_status(:unprocessable_entity)
287+
expect(response).to have_http_status(:unprocessable_content)
288288
end
289289

290290
it "shows the error page" do
@@ -313,7 +313,7 @@
313313

314314
it "returns a 422 response" do
315315
get form_page_path(mode:, form_id: 2, form_slug: form_data.form_slug, page_slug: 4)
316-
expect(response).to have_http_status(:unprocessable_entity)
316+
expect(response).to have_http_status(:unprocessable_content)
317317
end
318318

319319
it "shows the error page" do
@@ -331,7 +331,7 @@
331331

332332
it "returns a 422 response" do
333333
get form_page_path(mode:, form_id: 2, form_slug: form_data.form_slug, page_slug: 1)
334-
expect(response).to have_http_status(:unprocessable_entity)
334+
expect(response).to have_http_status(:unprocessable_content)
335335
end
336336

337337
it "shows the error page" do
@@ -426,7 +426,7 @@
426426
end
427427

428428
it "returns 422" do
429-
expect(response).to have_http_status(:unprocessable_entity)
429+
expect(response).to have_http_status(:unprocessable_content)
430430
end
431431

432432
it "adds validation_errors logging attribute" do
@@ -601,7 +601,7 @@
601601

602602
it "returns a 422 response" do
603603
post save_form_page_path(mode:, form_id: 2, form_slug: form_data.form_slug, page_slug: 1), params: { question: { selection: "Option 2" }, changing_existing_answer: false }
604-
expect(response).to have_http_status(:unprocessable_entity)
604+
expect(response).to have_http_status(:unprocessable_content)
605605
end
606606

607607
it "shows the error page" do

spec/requests/forms/remove_answer_controller_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
it "renders the show template" do
8383
delete "/preview-draft/#{form.id}/#{form.form_slug}/#{first_step_in_form.id}/1/remove", params: { remove_input: { remove: } }
8484
expect(response).to render_template(:show)
85-
expect(response).to have_http_status(:unprocessable_entity)
85+
expect(response).to have_http_status(:unprocessable_content)
8686
end
8787
end
8888

spec/requests/forms/remove_file_controller_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130

131131
it "renders the remove file page with 422 status" do
132132
expect(response).to render_template("forms/remove_file/show")
133-
expect(response).to have_http_status :unprocessable_entity
133+
expect(response).to have_http_status :unprocessable_content
134134
end
135135

136136
it "displays an error" do

0 commit comments

Comments
 (0)