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:
parent
b4d8c7d148
commit
4d256bc6b1
2 changed files with 11 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue