1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Refactor the test_unit scaffold generator to use the key_value method

This commit is contained in:
Rafael Mendonça França 2012-03-13 14:19:03 -03:00
parent 21b69b233b
commit 7c00cde79f
3 changed files with 9 additions and 9 deletions

View file

@ -26,7 +26,7 @@ module TestUnit
accessible_attributes.map do |a|
name = a.name
"#{name}: @#{singular_table_name}.#{name}"
key_value name, "@#{singular_table_name}.#{name}"
end.sort.join(', ')
end

View file

@ -75,8 +75,8 @@ 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)
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
@ -86,8 +86,8 @@ 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: { }/, content)
assert_match(/put :update, id: @user, user: { }/, content)
assert_match(/post :create, user: \{ \}/, content)
assert_match(/put :update, id: @user, user: \{ \}/, content)
end
end

View file

@ -64,8 +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(/post :create, product_line: { title: @product_line.title }/, test)
assert_match(/put :update, id: @product_line, product_line: { title: @product_line.title }/, 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
@ -94,8 +94,8 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
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)
assert_match(/post :create, product_line: \{ \}/, content)
assert_match(/put :update, id: @product_line, product_line: \{ \}/, content)
end
end