aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorGenadi Samokovarov <gsamokovarov@gmail.com>2015-12-13 19:37:22 +0100
committerGenadi Samokovarov <gsamokovarov@gmail.com>2015-12-13 20:18:19 +0100
commitc83ace7b6a5720be30a2f7d843d545fc81af54cd (patch)
tree2084a99088604dc00be5ea89be544caf94099273 /railties/test
parenteb0e8e216fcf535a1e6b82720dfb7639fcc20ff2 (diff)
downloadrails-c83ace7b6a5720be30a2f7d843d545fc81af54cd.tar.gz
rails-c83ace7b6a5720be30a2f7d843d545fc81af54cd.tar.bz2
rails-c83ace7b6a5720be30a2f7d843d545fc81af54cd.zip
Prevent a 500 in the default controller scaffold
If you update a record with no attributes, you'll hit a 500 from a guard in `assign_attributes` raising: ```ruby ArgumentError: When assigning attributes, you must pass a hash as an argument. app/controllers/users_controller.rb:44:in `block in update' app/controllers/users_controller.rb:43:in `update' test/controllers/users_controller_test.rb:37:in `block in <class:UsersControllerTest>' ``` Not a biggie, but may be quite confusing for the folks new to the framework.
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/generators/scaffold_controller_generator_test.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/railties/test/generators/scaffold_controller_generator_test.rb b/railties/test/generators/scaffold_controller_generator_test.rb
index 95ef853a11..b4ba101017 100644
--- a/railties/test/generators/scaffold_controller_generator_test.rb
+++ b/railties/test/generators/scaffold_controller_generator_test.rb
@@ -56,7 +56,7 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
assert_file "app/controllers/users_controller.rb" do |content|
assert_match(/def user_params/, content)
- assert_match(/params\[:user\]/, content)
+ assert_match(/params\.fetch\(:user, \{\}\)/, content)
end
end