commands are reversed

This commit is contained in:
Aaron Patterson 2010-11-18 15:09:25 -08:00
parent 5d93900dc6
commit b29a24bb6f
2 changed files with 8 additions and 1 deletions

View File

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

View File

@ -20,6 +20,13 @@ module ActiveRecord
assert_equal 2, @recorder.inverse.length assert_equal 2, @recorder.inverse.length
end end
def test_inverted_commands_are_reveresed
@recorder.record :create_table, [:hello]
@recorder.record :create_table, [:world]
tables = @recorder.inverse.map(&:last)
assert_equal [[:world], [:hello]], tables
end
def test_invert_create_table def test_invert_create_table
@recorder.record :create_table, [:system_settings] @recorder.record :create_table, [:system_settings]
drop_table = @recorder.inverse.first drop_table = @recorder.inverse.first