diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-02-28 15:34:30 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-02-28 16:31:22 +0900 |
commit | 310dc5dc443023ca4231eb0788e34ef6d157fa06 (patch) | |
tree | ed95796a892cdf71c47671dd37aa87de6245176a /activerecord/test/cases | |
parent | d50380f4e3f9e8d9398c8fdcbe5f52f784d14f5f (diff) | |
download | rails-310dc5dc443023ca4231eb0788e34ef6d157fa06.tar.gz rails-310dc5dc443023ca4231eb0788e34ef6d157fa06.tar.bz2 rails-310dc5dc443023ca4231eb0788e34ef6d157fa06.zip |
`create_join_table` should respect `references` column type
Follow up of #26266.
The default type of `primary_key` and `references` were changed to
`bigint` since #26266. But `create_join_table` column type is still
`integer`. It should respect `references` column type.
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/migration/create_join_table_test.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/activerecord/test/cases/migration/create_join_table_test.rb b/activerecord/test/cases/migration/create_join_table_test.rb index 26b1bb4419..c4896f3d6e 100644 --- a/activerecord/test/cases/migration/create_join_table_test.rb +++ b/activerecord/test/cases/migration/create_join_table_test.rb @@ -12,7 +12,7 @@ module ActiveRecord teardown do %w(artists_musics musics_videos catalog).each do |table_name| - connection.drop_table table_name if connection.table_exists?(table_name) + connection.drop_table table_name, if_exists: true end end @@ -78,6 +78,17 @@ module ActiveRecord assert_equal [%w(artist_id music_id)], connection.indexes(:artists_musics).map(&:columns) end + def test_create_join_table_respects_reference_key_type + connection.create_join_table :artists, :musics do |t| + t.references :video + end + + artist_id, music_id, video_id = connection.columns(:artists_musics).sort_by(&:name) + + assert_equal video_id.sql_type, artist_id.sql_type + assert_equal video_id.sql_type, music_id.sql_type + end + def test_drop_join_table connection.create_join_table :artists, :musics connection.drop_join_table :artists, :musics |