diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-03-13 11:57:28 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-03-13 11:57:28 -0300 |
commit | c1610ebc28ced5cabfe4f8d4903d60a75a949ac2 (patch) | |
tree | 8fdc811cf716902405d4deef0c48b1b97809d1e1 /railties | |
parent | ac8469d233821899283bcb7e6b0cd8d4203ffb35 (diff) | |
download | rails-c1610ebc28ced5cabfe4f8d4903d60a75a949ac2.tar.gz rails-c1610ebc28ced5cabfe4f8d4903d60a75a949ac2.tar.bz2 rails-c1610ebc28ced5cabfe4f8d4903d60a75a949ac2.zip |
Use Ruby 1.8 hash syntax
Diffstat (limited to 'railties')
3 files changed, 33 insertions, 9 deletions
diff --git a/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb b/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb index 4c07baae36..8e796aada9 100644 --- a/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +++ b/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb @@ -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 diff --git a/railties/test/generators/scaffold_controller_generator_test.rb b/railties/test/generators/scaffold_controller_generator_test.rb index dafaee8800..7c28f5914f 100644 --- a/railties/test/generators/scaffold_controller_generator_test.rb +++ b/railties/test/generators/scaffold_controller_generator_test.rb @@ -75,8 +75,14 @@ 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) + + 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 @@ -86,8 +92,14 @@ 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) + + 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 diff --git a/railties/test/generators/scaffold_generator_test.rb b/railties/test/generators/scaffold_generator_test.rb index f4f0147156..2710ef7dfd 100644 --- a/railties/test/generators/scaffold_generator_test.rb +++ b/railties/test/generators/scaffold_generator_test.rb @@ -64,8 +64,14 @@ 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) + + 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 @@ -94,8 +100,14 @@ 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) + + 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 |