aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-03-12 20:10:40 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-03-13 11:21:29 -0300
commit08db3d5af3ac6a36036083e80f7bb33e65cc9dd3 (patch)
tree1e88fd6a2554cf56759325f5c1580b7a370af0cf /railties/test
parent7ad4c7c8814dc04a2d70967d887d2035b4d71b37 (diff)
downloadrails-08db3d5af3ac6a36036083e80f7bb33e65cc9dd3.tar.gz
rails-08db3d5af3ac6a36036083e80f7bb33e65cc9dd3.tar.bz2
rails-08db3d5af3ac6a36036083e80f7bb33e65cc9dd3.zip
Use the attributes hash explicitly
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/generators/scaffold_controller_generator_test.rb16
-rw-r--r--railties/test/generators/scaffold_generator_test.rb16
2 files changed, 26 insertions, 6 deletions
diff --git a/railties/test/generators/scaffold_controller_generator_test.rb b/railties/test/generators/scaffold_controller_generator_test.rb
index 85b3a4ef61..03a753151d 100644
--- a/railties/test/generators/scaffold_controller_generator_test.rb
+++ b/railties/test/generators/scaffold_controller_generator_test.rb
@@ -75,9 +75,19 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
assert_file "test/functional/users_controller_test.rb" do |content|
assert_match(/class UsersControllerTest < ActionController::TestCase/, content)
assert_match(/test "should get index"/, content)
- assert_match(/@valid_attributes = @user\.attributes\.slice\("age", "name"\)/, content)
- assert_match(/post :create, user: @valid_attributes/, content)
- assert_match(/put :update, id: @user, user: @valid_attributes/, content)
+ assert_match(/post :create, user: { age: @user.age, name: @user.name }/, content)
+ assert_match(/put :update, id: @user, user: { age: @user.age, name: @user.name }/, content)
+ end
+ end
+
+ def test_functional_tests_without_attributes
+ run_generator ["User"]
+
+ assert_file "test/functional/users_controller_test.rb" do |content|
+ assert_match(/class UsersControllerTest < ActionController::TestCase/, content)
+ assert_match(/test "should get index"/, content)
+ assert_match(/post :create, user: { }/, content)
+ assert_match(/put :update, id: @user, user: { }/, content)
end
end
diff --git a/railties/test/generators/scaffold_generator_test.rb b/railties/test/generators/scaffold_generator_test.rb
index d983ae8b49..f4f0147156 100644
--- a/railties/test/generators/scaffold_generator_test.rb
+++ b/railties/test/generators/scaffold_generator_test.rb
@@ -64,9 +64,8 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
assert_file "test/functional/product_lines_controller_test.rb" do |test|
assert_match(/class ProductLinesControllerTest < ActionController::TestCase/, test)
- assert_match(/@valid_attributes = @product_line\.attributes\.slice\("title"\)/, test)
- assert_match(/post :create, product_line: @valid_attributes/, test)
- assert_match(/put :update, id: @product_line, product_line: @valid_attributes/, test)
+ assert_match(/post :create, product_line: { title: @product_line.title }/, test)
+ assert_match(/put :update, id: @product_line, product_line: { title: @product_line.title }/, test)
end
# Views
@@ -89,6 +88,17 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
assert_file "app/assets/stylesheets/product_lines.css"
end
+ def test_functional_tests_without_attributes
+ run_generator ["product_line"]
+
+ assert_file "test/functional/product_lines_controller_test.rb" do |content|
+ assert_match(/class ProductLinesControllerTest < ActionController::TestCase/, content)
+ assert_match(/test "should get index"/, content)
+ assert_match(/post :create, product_line: { }/, content)
+ assert_match(/put :update, id: @product_line, product_line: { }/, content)
+ end
+ end
+
def test_scaffold_on_revoke
run_generator
run_generator ["product_line"], :behavior => :revoke