Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve migration/column_attributes_test.rb #25286

Merged
merged 1 commit into from
Aug 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 17 additions & 3 deletions activerecord/test/cases/migration/column_attributes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ def test_add_column_without_limit
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

Expand Down Expand Up @@ -97,7 +97,21 @@ def test_add_column_with_precision_and_scale
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
Expand Down