Add test that primary_key and reference columns should be identical type for `add_reference`

That test had existed for `t.references`, but I missed to add it for
`add_reference` in #27334.

7813fc2c1f/activerecord/test/cases/base_test.rb (L145-L150)
This commit is contained in:
Ryuta Kamizono 2020-11-13 20:00:25 +09:00
parent c8f9a627d9
commit 5266b6a1c7
1 changed files with 7 additions and 0 deletions

View File

@ -22,6 +22,13 @@ module ActiveRecord
assert column_exists?(table_name, :user_id, :integer)
end
def test_primary_key_and_references_columns_should_be_identical_type
add_reference table_name, :user
pk = connection.send(:column_for, :users, :id)
ref = connection.send(:column_for, table_name, :user_id)
assert_equal pk.sql_type, ref.sql_type
end
def test_does_not_create_reference_type_column
add_reference table_name, :taggable
assert_not column_exists?(table_name, :taggable_type, :string)