Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

CommandRecorder should delegate in method_missing where possible. Fix…

…es some tests in migration_test.rb under mysql. The problem was introduced in c278a2c.
  • Loading branch information...
commit 22bcb4e09308c686f26dfca90b6d50263b4ae926 1 parent b09ef6d
@jonleighton jonleighton authored
View
6 activerecord/lib/active_record/migration/command_recorder.rb
@@ -95,7 +95,11 @@ def invert_add_timestamps(args)
# 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
7 activerecord/test/cases/migration/command_recorder_test.rb
@@ -31,7 +31,12 @@ def create_table(name); end
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
Please sign in to comment.
Something went wrong with that request. Please try again.