diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-07-03 09:23:43 -0700 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-07-03 09:23:43 -0700 |
commit | 3adb24aa6be8c8fb131f07b523ff5dfd54580c1d (patch) | |
tree | d9b5016139c647e0e54629957a0d76f0173f9e03 /activerecord | |
parent | 17693a99ef37ca1444fbc9adb855f3ee49bc3102 (diff) | |
parent | 15f35c0ac0adb5cdec8dfdba407e2ad42172121e (diff) | |
download | rails-3adb24aa6be8c8fb131f07b523ff5dfd54580c1d.tar.gz rails-3adb24aa6be8c8fb131f07b523ff5dfd54580c1d.tar.bz2 rails-3adb24aa6be8c8fb131f07b523ff5dfd54580c1d.zip |
Merge pull request #1941 from vijaydev/command-recorder-fix
Reversing the changes related to CommandRecorder
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/migration/command_recorder.rb | 14 | ||||
-rw-r--r-- | activerecord/test/cases/migration/command_recorder_test.rb | 8 |
2 files changed, 8 insertions, 14 deletions
diff --git a/activerecord/lib/active_record/migration/command_recorder.rb b/activerecord/lib/active_record/migration/command_recorder.rb index 4a01313c61..311789aa7f 100644 --- a/activerecord/lib/active_record/migration/command_recorder.rb +++ b/activerecord/lib/active_record/migration/command_recorder.rb @@ -48,7 +48,7 @@ module ActiveRecord super || delegate.respond_to?(*args) end - [:create_table, :rename_table, :add_column, :remove_column, :rename_index, :rename_column, :add_index, :remove_index, :add_timestamps, :remove_timestamps, :change_column, :change_column_default].each do |method| + [:create_table, :change_table, :rename_table, :add_column, :remove_column, :rename_index, :rename_column, :add_index, :remove_index, :add_timestamps, :remove_timestamps, :change_column, :change_column_default].each do |method| class_eval <<-EOV, __FILE__, __LINE__ + 1 def #{method}(*args) # def create_table(*args) record(:"#{method}", args) # record(:create_table, args) @@ -93,15 +93,11 @@ module ActiveRecord [:remove_timestamps, args] end - # Record all the methods called in the +change+ method of a migration. - # This will ensure that IrreversibleMigration is raised when the corresponding - # invert_method does not exist while the migration is rolled back. + # Forwards any missing method call to the \target. def method_missing(method, *args, &block) - if delegate.respond_to?(method) - delegate.send(method, *args, &block) - else - record(method, args) - end + @delegate.send(method, *args, &block) + rescue NoMethodError => e + raise e, e.message.sub(/ for #<.*$/, " via proxy for #{@delegate}") end end diff --git a/activerecord/test/cases/migration/command_recorder_test.rb b/activerecord/test/cases/migration/command_recorder_test.rb index 85d38fac25..36007255fa 100644 --- a/activerecord/test/cases/migration/command_recorder_test.rb +++ b/activerecord/test/cases/migration/command_recorder_test.rb @@ -14,11 +14,9 @@ module ActiveRecord assert recorder.respond_to?(:america) end - def test_non_existing_method_records_and_raises_on_inversion - @recorder.send(:non_existing_method, :horses) - assert_equal 1, @recorder.commands.length - assert_raises(ActiveRecord::IrreversibleMigration) do - @recorder.inverse + def test_send_calls_super + assert_raises(NoMethodError) do + @recorder.send(:non_existing_method, :horses) end end |