diff options
-rw-r--r-- | railties/lib/rails/generators/generated_attribute.rb | 4 | ||||
-rw-r--r-- | railties/test/generators/migration_generator_test.rb | 14 | ||||
-rw-r--r-- | railties/test/generators/model_generator_test.rb | 12 |
3 files changed, 15 insertions, 15 deletions
diff --git a/railties/lib/rails/generators/generated_attribute.rb b/railties/lib/rails/generators/generated_attribute.rb index 964bd6280c..61479b9068 100644 --- a/railties/lib/rails/generators/generated_attribute.rb +++ b/railties/lib/rails/generators/generated_attribute.rb @@ -96,11 +96,11 @@ module Rails end def inject_options - @attr_options.blank? ? '' : ", #{@attr_options.to_s.gsub(/[{}]/, '')}" + "".tap { |s| @attr_options.each { |k,v| s << ", #{k}: #{v.inspect}" } } end def inject_index_options - has_uniq_index? ? ", :unique => true" : '' + has_uniq_index? ? ", unique: true" : "" end end end diff --git a/railties/test/generators/migration_generator_test.rb b/railties/test/generators/migration_generator_test.rb index d81fc59fbf..68fbd58061 100644 --- a/railties/test/generators/migration_generator_test.rb +++ b/railties/test/generators/migration_generator_test.rb @@ -69,7 +69,7 @@ class MigrationGeneratorTest < Rails::Generators::TestCase assert_match(/add_column :posts, :user_id, :integer/, up) end assert_match(/add_index :posts, :title/, content) - assert_match(/add_index :posts, :user_id, :unique => true/, content) + assert_match(/add_index :posts, :user_id, unique: true/, content) end end @@ -99,7 +99,7 @@ class MigrationGeneratorTest < Rails::Generators::TestCase assert_match(/add_column :posts, :user_uuid, :string/, up) end assert_match(/add_index :posts, :title/, content) - assert_match(/add_index :posts, :user_uuid, :unique => true/, content) + assert_match(/add_index :posts, :user_uuid, unique: true/, content) end end @@ -109,14 +109,14 @@ class MigrationGeneratorTest < Rails::Generators::TestCase assert_migration "db/migrate/#{migration}.rb" do |content| assert_method :change, content do |up| - assert_match(/add_column :books, :title, :string, :limit=>40/, up) - assert_match(/add_column :books, :content, :string, :limit=>255/, up) - assert_match(/add_column :books, :price, :decimal, :precision=>5, :scale=>2/, up) - assert_match(/add_column :books, :discount, :decimal, :precision=>3, :scale=>2/, up) + assert_match(/add_column :books, :title, :string, limit: 40/, up) + assert_match(/add_column :books, :content, :string, limit: 255/, up) + assert_match(/add_column :books, :price, :decimal, precision: 5, scale: 2/, up) + assert_match(/add_column :books, :discount, :decimal, precision: 3, scale: 2/, up) end assert_match(/add_index :books, :title/, content) assert_match(/add_index :books, :price/, content) - assert_match(/add_index :books, :discount, :unique => true/, content) + assert_match(/add_index :books, :discount, unique: true/, content) end end diff --git a/railties/test/generators/model_generator_test.rb b/railties/test/generators/model_generator_test.rb index ffb3d2ceba..156fa86eee 100644 --- a/railties/test/generators/model_generator_test.rb +++ b/railties/test/generators/model_generator_test.rb @@ -126,8 +126,8 @@ class ModelGeneratorTest < Rails::Generators::TestCase assert_match(/add_index :products, :name/, up) assert_match(/add_index :products, :supplier_id/, up) - assert_match(/add_index :products, :user_id, :unique => true/, up) - assert_match(/add_index :products, :order_id, :unique => true/, up) + assert_match(/add_index :products, :user_id, unique: true/, up) + assert_match(/add_index :products, :order_id, unique: true/, up) end end end @@ -171,13 +171,13 @@ class ModelGeneratorTest < Rails::Generators::TestCase assert_migration "db/migrate/create_products.rb" do |content| assert_method :change, content do |up| assert_match(/create_table :products/, up) - assert_match(/t.string :title, :limit=>40/, up) - assert_match(/t.string :content, :limit=>255/, up) - assert_match(/t.decimal :price, :precision=>5, :scale=>2/, up) + assert_match(/t.string :title, limit: 40/, up) + assert_match(/t.string :content, limit: 255/, up) + assert_match(/t.decimal :price, precision: 5, scale: 2/, up) end assert_match(/add_index :products, :title/, content) assert_match(/add_index :products, :price/, content) - assert_match(/add_index :products, :discount, :unique => true/, content) + assert_match(/add_index :products, :discount, unique: true/, content) end end |