aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-05-13 11:03:37 +0900
committerGitHub <noreply@github.com>2018-05-13 11:03:37 +0900
commit8cfa34626c56b1e52328194e380d661785a7b082 (patch)
tree81a4bf283699f0f554087d0dace530a9052bfdbc /activerecord/test/cases
parent6fac9bd599eeb6b9cacdf7841811223402c501bd (diff)
parent2f29380c18d7754cefffbc09bebaa2007fb99929 (diff)
downloadrails-8cfa34626c56b1e52328194e380d661785a7b082.tar.gz
rails-8cfa34626c56b1e52328194e380d661785a7b082.tar.bz2
rails-8cfa34626c56b1e52328194e380d661785a7b082.zip
Merge pull request #32862 from eugeneius/callback_rollback
Don't clear transaction state after manual rollback
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/transactions_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/cases/transactions_test.rb b/activerecord/test/cases/transactions_test.rb
index 3fd38b4b60..931e01845a 100644
--- a/activerecord/test/cases/transactions_test.rb
+++ b/activerecord/test/cases/transactions_test.rb
@@ -292,6 +292,18 @@ class TransactionTest < ActiveRecord::TestCase
assert_nil new_topic.id, "The topic should not have an ID"
end
+ def test_callback_rollback_in_create_with_rollback_exception
+ topic = Class.new(Topic) {
+ def after_create_for_transaction
+ raise ActiveRecord::Rollback
+ end
+ }
+
+ new_topic = topic.create(title: "A new topic")
+ assert !new_topic.persisted?, "The topic should not be persisted"
+ assert_nil new_topic.id, "The topic should not have an ID"
+ end
+
def test_nested_explicit_transactions
Topic.transaction do
Topic.transaction do