Skip to content
Browse files

Don't rewrite AR connection#commit_db_transaction method globally

  • Loading branch information...
1 parent 516606b commit f0942a7c236ba87a034f65827ddd2706c5c48ca3 @amatsuda amatsuda committed Jul 26, 2013
Showing with 4 additions and 4 deletions.
  1. +4 −4 activerecord/test/cases/transaction_callbacks_test.rb
View
8 activerecord/test/cases/transaction_callbacks_test.rb
@@ -182,9 +182,9 @@ def test_only_call_after_rollback_on_create_after_transaction_rollsback_for_new_
end
def test_call_after_rollback_when_commit_fails
- @first.class.connection.class.send(:alias_method, :real_method_commit_db_transaction, :commit_db_transaction)
+ @first.class.connection.singleton_class.send(:alias_method, :real_method_commit_db_transaction, :commit_db_transaction)
begin
- @first.class.connection.class.class_eval do
+ @first.class.connection.singleton_class.class_eval do
def commit_db_transaction; raise "boom!"; end
end
@@ -194,8 +194,8 @@ def commit_db_transaction; raise "boom!"; end
assert !@first.save rescue nil
assert_equal [:after_rollback], @first.history
ensure
- @first.class.connection.class.send(:remove_method, :commit_db_transaction)
- @first.class.connection.class.send(:alias_method, :commit_db_transaction, :real_method_commit_db_transaction)
+ @first.class.connection.singleton_class.send(:remove_method, :commit_db_transaction)
+ @first.class.connection.singleton_class.send(:alias_method, :commit_db_transaction, :real_method_commit_db_transaction)
end
end

0 comments on commit f0942a7

Please sign in to comment.
Something went wrong with that request. Please try again.