Skip to content

Commit

Permalink
Use Ruby 1.8 hash syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca committed Mar 13, 2012
1 parent ac8469d commit c1610eb
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
Expand Up @@ -26,7 +26,7 @@ def attributes_hash

accessible_attributes.map do |a|
name = a.name
"#{name}: @#{singular_table_name}.#{name}"
key_value name, "@#{singular_table_name}.#{name}"
end.sort.join(', ')
end

Expand Down
20 changes: 16 additions & 4 deletions railties/test/generators/scaffold_controller_generator_test.rb
Expand Up @@ -75,8 +75,14 @@ def test_functional_tests
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)

if RUBY_VERSION < "1.9"
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)
else
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
end

Expand All @@ -86,8 +92,14 @@ def test_functional_tests_without_attributes
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)

if RUBY_VERSION < "1.9"
assert_match(/post :create, :user => \{ \}/, content)
assert_match(/put :update, :id => @user, :user => \{ \}/, content)
else
assert_match(/post :create, user: \{ \}/, content)
assert_match(/put :update, id: @user, user: \{ \}/, content)
end
end
end

Expand Down
20 changes: 16 additions & 4 deletions railties/test/generators/scaffold_generator_test.rb
Expand Up @@ -64,8 +64,14 @@ def test_scaffold_on_invoke

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)

if RUBY_VERSION < "1.9"
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)
else
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
end

# Views
Expand Down Expand Up @@ -94,8 +100,14 @@ def test_functional_tests_without_attributes
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)

if RUBY_VERSION < "1.9"
assert_match(/post :create, :product_line => \{ \}/, content)
assert_match(/put :update, :id => @product_line, :product_line => \{ \}/, content)
else
assert_match(/post :create, product_line: \{ \}/, content)
assert_match(/put :update, id: @product_line, product_line: \{ \}/, content)
end
end
end

Expand Down

0 comments on commit c1610eb

Please sign in to comment.