aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2013-07-14 20:06:01 -0700
committerSantiago Pastorino <santiago@wyeworks.com>2013-07-14 20:06:01 -0700
commit8833b82df0df699aa0cc97ca1212174f5902697f (patch)
tree34f72c17ddb7a43791bdfeb0709ac59ec4255193 /activerecord/test
parent5979bc9e11d68e11458a27037edffaa368990f27 (diff)
parente0d59e6219c752d8cffc6b78c2240755f5728922 (diff)
downloadrails-8833b82df0df699aa0cc97ca1212174f5902697f.tar.gz
rails-8833b82df0df699aa0cc97ca1212174f5902697f.tar.bz2
rails-8833b82df0df699aa0cc97ca1212174f5902697f.zip
Merge pull request #11434 from jetthoughts/new_save_transaction_bugfix
Remove extra decrement of transaction level
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/transactions_test.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/test/cases/transactions_test.rb b/activerecord/test/cases/transactions_test.rb
index c0cad52b22..9c5f2e4724 100644
--- a/activerecord/test/cases/transactions_test.rb
+++ b/activerecord/test/cases/transactions_test.rb
@@ -117,6 +117,20 @@ class TransactionTest < ActiveRecord::TestCase
assert !Topic.find(1).approved?
end
+ def test_raising_exception_in_nested_transaction_restore_state_in_save
+ topic = Topic.new
+
+ def topic.after_save_for_transaction
+ raise 'Make the transaction rollback'
+ end
+
+ assert_raises(RuntimeError) do
+ Topic.transaction { topic.save }
+ end
+
+ assert topic.new_record?, "#{topic.inspect} should be new record"
+ end
+
def test_update_should_rollback_on_failure
author = Author.find(1)
posts_count = author.posts.size