diff options
author | Marc-Andre Lafortune <github@marc-andre.ca> | 2012-11-19 02:12:40 -0500 |
---|---|---|
committer | Marc-Andre Lafortune <github@marc-andre.ca> | 2012-12-21 13:54:52 -0500 |
commit | 313232463d2a378cb3d14a34f5334cc4bd7a07b8 (patch) | |
tree | 6f0ef6a8632d3a08179004d8ae7d4fbb06ba621f /activerecord/test/cases/migration | |
parent | e28ddea098d0422bae08324fb1d72f2b100152d0 (diff) | |
download | rails-313232463d2a378cb3d14a34f5334cc4bd7a07b8.tar.gz rails-313232463d2a378cb3d14a34f5334cc4bd7a07b8.tar.bz2 rails-313232463d2a378cb3d14a34f5334cc4bd7a07b8.zip |
Make remove_index reversible [#8267]
Diffstat (limited to 'activerecord/test/cases/migration')
-rw-r--r-- | activerecord/test/cases/migration/command_recorder_test.rb | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/activerecord/test/cases/migration/command_recorder_test.rb b/activerecord/test/cases/migration/command_recorder_test.rb index 8ebc1adaa6..c12ffb0b4c 100644 --- a/activerecord/test/cases/migration/command_recorder_test.rb +++ b/activerecord/test/cases/migration/command_recorder_test.rb @@ -148,17 +148,38 @@ module ActiveRecord def test_invert_add_index remove = @recorder.inverse_of :add_index, [:table, [:one, :two], options: true] - assert_equal [:remove_index, [:table, {:column => [:one, :two]}]], remove + assert_equal [:remove_index, [:table, {column: [:one, :two], options: true}]], remove end def test_invert_add_index_with_name remove = @recorder.inverse_of :add_index, [:table, [:one, :two], name: "new_index"] - assert_equal [:remove_index, [:table, {:name => "new_index"}]], remove + assert_equal [:remove_index, [:table, {column: [:one, :two], name: "new_index"}]], remove end def test_invert_add_index_with_no_options remove = @recorder.inverse_of :add_index, [:table, [:one, :two]] - assert_equal [:remove_index, [:table, {:column => [:one, :two]}]], remove + assert_equal [:remove_index, [:table, {column: [:one, :two]}]], remove + end + + def test_invert_remove_index + add = @recorder.inverse_of :remove_index, [:table, {column: [:one, :two], options: true}] + assert_equal [:add_index, [:table, [:one, :two], options: true]], add + end + + def test_invert_remove_index_with_name + add = @recorder.inverse_of :remove_index, [:table, {column: [:one, :two], name: "new_index"}] + assert_equal [:add_index, [:table, [:one, :two], name: "new_index"]], add + end + + def test_invert_remove_index_with_no_special_options + add = @recorder.inverse_of :remove_index, [:table, {column: [:one, :two]}] + assert_equal [:add_index, [:table, [:one, :two], {}]], add + end + + def test_invert_remove_index_with_no_column + assert_raises(ActiveRecord::IrreversibleMigration) do + @recorder.inverse_of :remove_index, [:table, name: "new_index"] + end end def test_invert_rename_index |