Permalink
Browse files

Fix broken testcase for transactions

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2409 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
seckar committed Sep 29, 2005
1 parent 438db96 commit 6f3804113329d407d134c235120ab2e1e8da5244
@@ -39,20 +39,24 @@ def delete(sql, name = nil) end
# Wrap a block in a transaction. Returns result of block.
def transaction(start_db_transaction = true)
- needs_commit = false
+ transaction_open = false
begin
if block_given?
- begin_db_transaction if start_db_transaction
- needs_commit = start_db_transaction
+ if start_db_transaction
+ begin_db_transaction
+ transaction_open = true
+ end
yield
end
rescue Exception => database_transaction_rollback
- rollback_db_transaction if start_db_transaction
- needs_commit = false
+ if transaction_open
+ transaction_open = false
+ rollback_db_transaction
+ end
raise
end
ensure
- commit_db_transaction if needs_commit
+ commit_db_transaction if transaction_open
end
# Begins the transaction (and turns off auto-committing).
@@ -40,7 +40,7 @@ class << Topic.connection
alias :real_commit_db_transaction :commit_db_transaction
def commit_db_transaction
$committed = true
- :real_commit_db_transaction
+ real_commit_db_transaction
end
end

0 comments on commit 6f38041

Please sign in to comment.