Skip to content

Commit 418cd97

Browse files
authored
Merge pull request #583 from excid3/update-see-other
2 parents 2ccbd6f + 1147718 commit 418cd97

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/generators/rails/templates/controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def create
4343
def update
4444
respond_to do |format|
4545
if @<%= orm_instance.update("#{singular_table_name}_params") %>
46-
format.html { redirect_to <%= redirect_resource_name %>, notice: <%= %("#{human_name} was successfully updated.") %> }
46+
format.html { redirect_to <%= redirect_resource_name %>, notice: <%= %("#{human_name} was successfully updated.") %>, status: :see_other }
4747
format.json { render :show, status: :ok, location: <%= "@#{singular_table_name}" %> }
4848
else
4949
format.html { render :edit, status: :unprocessable_entity }
@@ -57,7 +57,7 @@ def destroy
5757
@<%= orm_instance.destroy %>
5858
5959
respond_to do |format|
60-
format.html { redirect_to <%= index_helper %>_path, status: :see_other, notice: <%= %("#{human_name} was successfully destroyed.") %> }
60+
format.html { redirect_to <%= index_helper %>_path, notice: <%= %("#{human_name} was successfully destroyed.") %>, status: :see_other }
6161
format.json { head :no_content }
6262
end
6363
end

test/scaffold_controller_generator_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
3838
end
3939

4040
assert_instance_method :update, content do |m|
41-
assert_match %r{format\.html \{ redirect_to @post, notice: "Post was successfully updated\." \}}, m
41+
assert_match %r{format\.html \{ redirect_to @post, notice: "Post was successfully updated\.", status: :see_other \}}, m
4242
assert_match %r{format\.json \{ render :show, status: :ok, location: @post \}}, m
4343
assert_match %r{format\.html \{ render :edit, status: :unprocessable_entity \}}, m
4444
assert_match %r{format\.json \{ render json: @post.errors, status: :unprocessable_entity \}}, m
4545
end
4646

4747
assert_instance_method :destroy, content do |m|
4848
assert_match %r{@post\.destroy}, m
49-
assert_match %r{format\.html \{ redirect_to posts_path, status: :see_other, notice: "Post was successfully destroyed\." \}}, m
49+
assert_match %r{format\.html \{ redirect_to posts_path, notice: "Post was successfully destroyed\.", status: :see_other \}}, m
5050
assert_match %r{format\.json \{ head :no_content \}}, m
5151
end
5252

@@ -77,11 +77,11 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
7777
end
7878

7979
assert_instance_method :update, content do |m|
80-
assert_match %r{format\.html \{ redirect_to \[:admin, @post\], notice: "Post was successfully updated\." \}}, m
80+
assert_match %r{format\.html \{ redirect_to \[:admin, @post\], notice: "Post was successfully updated\.", status: :see_other \}}, m
8181
end
8282

8383
assert_instance_method :destroy, content do |m|
84-
assert_match %r{format\.html \{ redirect_to admin_posts_path, status: :see_other, notice: "Post was successfully destroyed\." \}}, m
84+
assert_match %r{format\.html \{ redirect_to admin_posts_path, notice: "Post was successfully destroyed\.", status: :see_other \}}, m
8585
end
8686
end
8787
end

0 commit comments

Comments
 (0)