Skip to content

Commit

Permalink
Add missing ':see_other' status code when redirecting in the generate…
Browse files Browse the repository at this point in the history
…d destroy controller method
  • Loading branch information
ldeld committed Aug 25, 2022
1 parent 7ab0e35 commit c72e211
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/generators/rails/templates/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/scaffold_controller_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -72,7 +72,7 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
end

assert_instance_method :destroy, content do |m|
assert_match %r{format\.html \{ redirect_to admin_posts_url, notice: "Post was successfully destroyed\." \}}, m
assert_match %r{format\.html \{ redirect_to admin_posts_url, status: :see_other, notice: "Post was successfully destroyed\." \}}, m
end
end
end
Expand Down

0 comments on commit c72e211

Please sign in to comment.