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:
parent
9ebe582830
commit
69789c3b29
2 changed files with 23 additions and 2 deletions
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue