aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2017-02-28 17:54:03 -0500
committerGitHub <noreply@github.com>2017-02-28 17:54:03 -0500
commit4f384678b639b924b481ec4959f9b93b9d34061c (patch)
treee840cf1ec2724b9f3e552c112992609b7b039859 /activerecord/test/cases
parent6a7bd6e2e4a4f408781fdfbbfb9508b5a872e9f6 (diff)
parent310dc5dc443023ca4231eb0788e34ef6d157fa06 (diff)
downloadrails-4f384678b639b924b481ec4959f9b93b9d34061c.tar.gz
rails-4f384678b639b924b481ec4959f9b93b9d34061c.tar.bz2
rails-4f384678b639b924b481ec4959f9b93b9d34061c.zip
Merge pull request #28217 from kamipo/create_join_table_respects_reference_key_type
`create_join_table` should respect `references` column type
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/migration/create_join_table_test.rb13
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