aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/migration
diff options
context:
space:
mode:
authorRich <jychen7@users.noreply.github.com>2018-08-06 14:00:22 +0800
committerRich <jychen7@users.noreply.github.com>2018-08-14 21:52:11 +0800
commit6b9948c85e174b77b4e4e4a904c2b6fcf1083628 (patch)
tree19b6ae0b19077d92c4f5faf6f1ccaa9f876fea22 /activerecord/test/cases/migration
parentffc4703f22888dce0394fe0ab524a9e6cdc3c7e5 (diff)
downloadrails-6b9948c85e174b77b4e4e4a904c2b6fcf1083628.tar.gz
rails-6b9948c85e174b77b4e4e4a904c2b6fcf1083628.tar.bz2
rails-6b9948c85e174b77b4e4e4a904c2b6fcf1083628.zip
Allow `to_table` in `invert_remove_foreign_key`
remove_foreign_key supports - remove_foreign_key :accounts, :branches - remove_foreign_key :accounts, to_table: :branches but the second one is not reversible. This branch is to fix and allow second one to be reversible. [Nikolay Epifanov, Rich Chen]
Diffstat (limited to 'activerecord/test/cases/migration')
-rw-r--r--activerecord/test/cases/migration/command_recorder_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/migration/command_recorder_test.rb b/activerecord/test/cases/migration/command_recorder_test.rb
index 3a11bb081b..daca296ade 100644
--- a/activerecord/test/cases/migration/command_recorder_test.rb
+++ b/activerecord/test/cases/migration/command_recorder_test.rb
@@ -334,6 +334,14 @@ module ActiveRecord
assert_equal [:add_foreign_key, [:dogs, :people, on_delete: :nullify, on_update: :cascade]], enable
end
+ def test_invert_remove_foreign_key_with_to_table_in_options
+ enable = @recorder.inverse_of :remove_foreign_key, [:dogs, to_table: :people]
+ assert_equal [:add_foreign_key, [:dogs, :people]], enable
+
+ enable = @recorder.inverse_of :remove_foreign_key, [:dogs, to_table: :people, column: :owner_id]
+ assert_equal [:add_foreign_key, [:dogs, :people, column: :owner_id]], enable
+ end
+
def test_invert_remove_foreign_key_is_irreversible_without_to_table
assert_raises ActiveRecord::IrreversibleMigration do
@recorder.inverse_of :remove_foreign_key, [:dogs, column: "owner_id"]