From d1b45ecf89409ff8afe18fb61b1404db72e8d31e Mon Sep 17 00:00:00 2001 From: Lorenzo Del Castillo Date: Thu, 25 Aug 2022 20:29:24 +0200 Subject: [PATCH] Add missing ':see_other' status code when redirecting in the generated destroy controller method --- lib/generators/rails/templates/controller.rb | 2 +- test/scaffold_controller_generator_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/generators/rails/templates/controller.rb b/lib/generators/rails/templates/controller.rb index 92f5da78..3dc5f41a 100644 --- a/lib/generators/rails/templates/controller.rb +++ b/lib/generators/rails/templates/controller.rb @@ -57,7 +57,7 @@ def destroy @<%= orm_instance.destroy %> respond_to do |format| - format.html { redirect_to <%= index_helper %>_url, notice: <%= %("#{human_name} was successfully destroyed.") %> } + format.html { redirect_to <%= index_helper %>_url, status: :see_other, notice: <%= %("#{human_name} was successfully destroyed.") %> } format.json { head :no_content } end end diff --git a/test/scaffold_controller_generator_test.rb b/test/scaffold_controller_generator_test.rb index 10bf26bf..010aadce 100644 --- a/test/scaffold_controller_generator_test.rb +++ b/test/scaffold_controller_generator_test.rb @@ -46,7 +46,7 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase assert_instance_method :destroy, content do |m| assert_match %r{@post\.destroy}, m - assert_match %r{format\.html \{ redirect_to posts_url, notice: "Post was successfully destroyed\." \}}, m + assert_match %r{format\.html \{ redirect_to posts_url, status: :see_other, notice: "Post was successfully destroyed\." \}}, m assert_match %r{format\.json \{ head :no_content \}}, m end