aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/migration/column_positioning_test.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-09-01 21:49:28 +0900
committerRyuta Kamizono <kamipo@gmail.com>2017-09-01 21:49:28 +0900
commit17faed96b48d6c6b0bd3e8f5c5b0117537fefa11 (patch)
treeedeecb518f7e4116764b03fa46d756c6eda9dfde /activerecord/test/cases/migration/column_positioning_test.rb
parent47200f502d4ae477545b3d7583f05db2df09c5ba (diff)
downloadrails-17faed96b48d6c6b0bd3e8f5c5b0117537fefa11.tar.gz
rails-17faed96b48d6c6b0bd3e8f5c5b0117537fefa11.tar.bz2
rails-17faed96b48d6c6b0bd3e8f5c5b0117537fefa11.zip
`add_reference` should respect column position for both reference id and type columns
Fixes #30496.
Diffstat (limited to 'activerecord/test/cases/migration/column_positioning_test.rb')
-rw-r--r--activerecord/test/cases/migration/column_positioning_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/migration/column_positioning_test.rb b/activerecord/test/cases/migration/column_positioning_test.rb
index 23414419dc..1c62a68cf9 100644
--- a/activerecord/test/cases/migration/column_positioning_test.rb
+++ b/activerecord/test/cases/migration/column_positioning_test.rb
@@ -52,6 +52,16 @@ module ActiveRecord
conn.change_column :testings, :second, :integer, after: :third
assert_equal %w(first third second), conn.columns(:testings).map(&:name)
end
+
+ def test_add_reference_with_positioning_first
+ conn.add_reference :testings, :new, polymorphic: true, first: true
+ assert_equal %w(new_id new_type first second third), conn.columns(:testings).map(&:name)
+ end
+
+ def test_add_reference_with_positioning_after
+ conn.add_reference :testings, :new, polymorphic: true, after: :first
+ assert_equal %w(first new_id new_type second third), conn.columns(:testings).map(&:name)
+ end
end
end
end