1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

IrreversibleMigration is raised if we cannot invert the command

This commit is contained in:
Aaron Patterson 2010-11-18 15:12:09 -08:00
parent b29a24bb6f
commit 96b50a0392
2 changed files with 12 additions and 1 deletions

View file

@ -20,7 +20,11 @@ module ActiveRecord
# Returns a list that represents commands that are the inverse of the
# commands stored in +commands+.
def inverse
@commands.reverse.map { |name, args| send(:"invert_#{name}", args) }
@commands.reverse.map { |name, args|
method = :"invert_#{name}"
raise IrreversibleMigration unless respond_to?(method, true)
send(method, args)
}
end
private

View file

@ -7,6 +7,13 @@ module ActiveRecord
@recorder = CommandRecorder.new
end
def test_unknown_commands_raise_exception
@recorder.record :execute, ['some sql']
assert_raises(ActiveRecord::IrreversibleMigration) do
@recorder.inverse
end
end
def test_record
@recorder.record :create_table, [:system_settings]
assert_equal 1, @recorder.commands.length