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 d1b45ec
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 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
2 changes: 1 addition & 1 deletion 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 Down

0 comments on commit d1b45ec

Please sign in to comment.