diff options
author | José Valim <jose.valim@gmail.com> | 2012-03-13 07:38:23 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2012-03-13 07:38:23 -0700 |
commit | 21b69b233bda5870274c84ef8178c9ad9a47c390 (patch) | |
tree | 099b7bbf48a1f72442d9952159ba1d396d62f90d /railties/test/generators | |
parent | e7d55f734aae204115d0a04a2db774ac364c1312 (diff) | |
parent | 08db3d5af3ac6a36036083e80f7bb33e65cc9dd3 (diff) | |
download | rails-21b69b233bda5870274c84ef8178c9ad9a47c390.tar.gz rails-21b69b233bda5870274c84ef8178c9ad9a47c390.tar.bz2 rails-21b69b233bda5870274c84ef8178c9ad9a47c390.zip |
Merge pull request #5397 from rafaelfranca/fix-scaffold
Do not use the attributes hash in the scaffold functional tests
Diffstat (limited to 'railties/test/generators')
-rw-r--r-- | railties/test/generators/scaffold_controller_generator_test.rb | 13 | ||||
-rw-r--r-- | railties/test/generators/scaffold_generator_test.rb | 18 |
2 files changed, 29 insertions, 2 deletions
diff --git a/railties/test/generators/scaffold_controller_generator_test.rb b/railties/test/generators/scaffold_controller_generator_test.rb index 1382133d7b..03a753151d 100644 --- a/railties/test/generators/scaffold_controller_generator_test.rb +++ b/railties/test/generators/scaffold_controller_generator_test.rb @@ -75,6 +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(/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 2db8090621..f4f0147156 100644 --- a/railties/test/generators/scaffold_generator_test.rb +++ b/railties/test/generators/scaffold_generator_test.rb @@ -62,8 +62,11 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase end end - assert_file "test/functional/product_lines_controller_test.rb", - /class ProductLinesControllerTest < ActionController::TestCase/ + assert_file "test/functional/product_lines_controller_test.rb" do |test| + assert_match(/class ProductLinesControllerTest < ActionController::TestCase/, 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 %w( @@ -85,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 |