Permalink
Browse files

#transaction on the instance level should take options as well

  • Loading branch information...
1 parent 9ebe582 commit 69789c3b29b9ee0b89928f4211060f470d0e0c44 @carllerche carllerche committed Oct 15, 2010
Showing with 23 additions and 2 deletions.
  1. +2 −2 activerecord/lib/active_record/transactions.rb
  2. +21 −0 activerecord/test/cases/transactions_test.rb
@@ -224,8 +224,8 @@ def after_rollback(*args, &block)
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 @@ def test_force_savepoint_in_nested_transaction
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

0 comments on commit 69789c3

Please sign in to comment.