diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-08-18 17:52:33 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-18 17:52:33 +0900 |
commit | c910fd82dcbb89799d21dcb60da5c1b5de48f5fc (patch) | |
tree | 322d2261af16765a3fca95fe11938c89e9f684d9 /activerecord/test/cases/migration/column_attributes_test.rb | |
parent | 53524818bf8cdc752f721f1a5ac944a1543466f4 (diff) | |
download | rails-c910fd82dcbb89799d21dcb60da5c1b5de48f5fc.tar.gz rails-c910fd82dcbb89799d21dcb60da5c1b5de48f5fc.tar.bz2 rails-c910fd82dcbb89799d21dcb60da5c1b5de48f5fc.zip |
Improve `migration/column_attributes_test.rb` (#25286)
* Test `test_unabstracted_database_dependent_types` for `PostgreSQLAdapter`
* Add `test_change_column_with_new_precision_and_scale` for `SQLite3Adapter`
* This test case and comment was lost at 28bb02a78fd47527bb7a208d01a4594bb212812c
Diffstat (limited to 'activerecord/test/cases/migration/column_attributes_test.rb')
-rw-r--r-- | activerecord/test/cases/migration/column_attributes_test.rb | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/activerecord/test/cases/migration/column_attributes_test.rb b/activerecord/test/cases/migration/column_attributes_test.rb index 9200d32caf..be6dc2acb1 100644 --- a/activerecord/test/cases/migration/column_attributes_test.rb +++ b/activerecord/test/cases/migration/column_attributes_test.rb @@ -45,11 +45,11 @@ module ActiveRecord assert_nil TestModel.columns_hash["description"].limit end - if current_adapter?(:Mysql2Adapter) + if current_adapter?(:Mysql2Adapter, :PostgreSQLAdapter) def test_unabstracted_database_dependent_types - add_column :test_models, :intelligence_quotient, :tinyint + add_column :test_models, :intelligence_quotient, :smallint TestModel.reset_column_information - assert_match(/tinyint/, TestModel.columns_hash["intelligence_quotient"].sql_type) + assert_match(/smallint/, TestModel.columns_hash["intelligence_quotient"].sql_type) end end @@ -99,7 +99,21 @@ module ActiveRecord assert_equal 7, wealth_column.scale end + # Test SQLite3 adapter specifically for decimal types with precision and scale + # attributes, since these need to be maintained in schema but aren't actually + # used in SQLite3 itself if current_adapter?(:SQLite3Adapter) + def test_change_column_with_new_precision_and_scale + connection.add_column "test_models", "wealth", :decimal, precision: 9, scale: 7 + + connection.change_column "test_models", "wealth", :decimal, precision: 12, scale: 8 + TestModel.reset_column_information + + wealth_column = TestModel.columns_hash["wealth"] + assert_equal 12, wealth_column.precision + assert_equal 8, wealth_column.scale + end + def test_change_column_preserve_other_column_precision_and_scale connection.add_column "test_models", "last_name", :string connection.add_column "test_models", "wealth", :decimal, precision: 9, scale: 7 |