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

CommandRecorder should delegate in method_missing where possible. Fixes some tests in migration_test.rb under mysql. The problem was introduced in c278a2c5e1.

This commit is contained in:
Jon Leighton 2011-06-30 00:47:35 +01:00
parent b4d8c7d148
commit 4d256bc6b1
2 changed files with 11 additions and 2 deletions

View file

@ -97,7 +97,11 @@ module ActiveRecord
# This will ensure that IrreversibleMigration is raised when the corresponding
# invert_method does not exist while the migration is rolled back.
def method_missing(method, *args, &block)
record(method, args)
if delegate.respond_to?(method)
delegate.send(method, *args, &block)
else
record(method, args)
end
end
end

View file

@ -31,7 +31,12 @@ module ActiveRecord
assert_equal [[:create_table, [:horses]]], recorder.commands
end
def test_unknown_commands_raise_exception
def test_unknown_commands_delegate
recorder = CommandRecorder.new(stub(:foo => 'bar'))
assert_equal 'bar', recorder.foo
end
def test_unknown_commands_raise_exception_if_they_cannot_delegate
@recorder.record :execute, ['some sql']
assert_raises(ActiveRecord::IrreversibleMigration) do
@recorder.inverse