1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

#transaction on the instance level should take options as well

This commit is contained in:
Carl Lerche 2010-10-14 21:27:40 -07:00
parent 9ebe582830
commit 69789c3b29
2 changed files with 23 additions and 2 deletions

View file

@ -224,8 +224,8 @@ module ActiveRecord
end
# See ActiveRecord::Transactions::ClassMethods for detailed documentation.
def transaction(&block)
self.class.transaction(&block)
def transaction(options = {}, &block)
self.class.transaction(options, &block)
end
def destroy #:nodoc:

View file

@ -263,6 +263,27 @@ class TransactionTest < ActiveRecord::TestCase
assert !@second.reload.approved?
end if Topic.connection.supports_savepoints?
def test_force_savepoint_on_instance
@first.transaction do
@first.approved = true
@second.approved = false
@first.save!
@second.save!
begin
@second.transaction :requires_new => true do
@first.happy = false
@first.save!
raise
end
rescue
end
end
assert @first.reload.approved?
assert !@second.reload.approved?
end if Topic.connection.supports_savepoints?
def test_no_savepoint_in_nested_transaction_without_force
Topic.transaction do
@first.approved = true