aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activerecord/test/cases/transactions_test.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/activerecord/test/cases/transactions_test.rb b/activerecord/test/cases/transactions_test.rb
index 0b5fda3817..bb4f2c8064 100644
--- a/activerecord/test/cases/transactions_test.rb
+++ b/activerecord/test/cases/transactions_test.rb
@@ -36,24 +36,24 @@ class TransactionTest < ActiveRecord::TestCase
end
end
- # FIXME: Get rid of this fucking global variable!
def test_successful_with_return
- class << Topic.connection
+ committed = false
+
+ Topic.connection.class_eval do
alias :real_commit_db_transaction :commit_db_transaction
- def commit_db_transaction
- $committed = true
+ define_method(:commit_db_transaction) do
+ committed = true
real_commit_db_transaction
end
end
- $committed = false
transaction_with_return
- assert $committed
+ assert committed
assert Topic.find(1).approved?, "First should have been approved"
assert !Topic.find(2).approved?, "Second should have been unapproved"
ensure
- class << Topic.connection
+ Topic.connection.class_eval do
remove_method :commit_db_transaction
alias :commit_db_transaction :real_commit_db_transaction rescue nil
end