aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorAleksey Magusev <lexmag@gmail.com>2012-07-02 23:42:31 +0400
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-07-03 13:25:25 -0300
commit057fa33c3bc5e1806315a4641a7e0d3c6cd46629 (patch)
tree6344c83f75c8b48d6ef1decbb5699efcbfa0bc5e /activerecord/test/cases
parentcfb24586b811177666cf0d085e3ab111195fb3ff (diff)
downloadrails-057fa33c3bc5e1806315a4641a7e0d3c6cd46629.tar.gz
rails-057fa33c3bc5e1806315a4641a7e0d3c6cd46629.tar.bz2
rails-057fa33c3bc5e1806315a4641a7e0d3c6cd46629.zip
Make references statements reversible
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/migration/command_recorder_test.rb30
1 files changed, 27 insertions, 3 deletions
diff --git a/activerecord/test/cases/migration/command_recorder_test.rb b/activerecord/test/cases/migration/command_recorder_test.rb
index 7d026961be..f2213ee6aa 100644
--- a/activerecord/test/cases/migration/command_recorder_test.rb
+++ b/activerecord/test/cases/migration/command_recorder_test.rb
@@ -110,9 +110,9 @@ module ActiveRecord
end
def test_invert_add_index_with_name
- @recorder.record :add_index, [:table, [:one, :two], {:name => "new_index"}]
- remove = @recorder.inverse.first
- assert_equal [:remove_index, [:table, {:name => "new_index"}]], remove
+ @recorder.record :add_index, [:table, [:one, :two], {:name => "new_index"}]
+ remove = @recorder.inverse.first
+ assert_equal [:remove_index, [:table, {:name => "new_index"}]], remove
end
def test_invert_add_index_with_no_options
@@ -138,6 +138,30 @@ module ActiveRecord
add = @recorder.inverse.first
assert_equal [:add_timestamps, [:table]], add
end
+
+ def test_invert_add_reference
+ @recorder.record :add_reference, [:table, :taggable, { polymorphic: true }]
+ remove = @recorder.inverse.first
+ assert_equal [:remove_reference, [:table, :taggable, { polymorphic: true }]], remove
+ end
+
+ def test_invert_add_belongs_to_alias
+ @recorder.record :add_belongs_to, [:table, :user]
+ remove = @recorder.inverse.first
+ assert_equal [:remove_reference, [:table, :user]], remove
+ end
+
+ def test_invert_remove_reference
+ @recorder.record :remove_reference, [:table, :taggable, { polymorphic: true }]
+ add = @recorder.inverse.first
+ assert_equal [:add_reference, [:table, :taggable, { polymorphic: true }]], add
+ end
+
+ def test_invert_remove_belongs_to_alias
+ @recorder.record :remove_belongs_to, [:table, :user]
+ add = @recorder.inverse.first
+ assert_equal [:add_reference, [:table, :user]], add
+ end
end
end
end