aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/transaction_callbacks_test.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-04-30 21:23:03 +0900
committerRyuta Kamizono <kamipo@gmail.com>2019-04-30 21:44:37 +0900
commite0a315b38aae8cb748597a89786c2249627c4495 (patch)
tree4af6b10b7c5ac2282ae4e57fb60756e3417abd0f /activerecord/test/cases/transaction_callbacks_test.rb
parentc1ff1392dbcd8fbf9228d552cf596a26351b2edc (diff)
downloadrails-e0a315b38aae8cb748597a89786c2249627c4495.tar.gz
rails-e0a315b38aae8cb748597a89786c2249627c4495.tar.bz2
rails-e0a315b38aae8cb748597a89786c2249627c4495.zip
Should take the record's state of first action in the transaction
If the same id's records are saved and/or destroyed in the transaction, commit callbackes will only run for the first enrolled record. https://github.com/rails/rails/blob/a023e2180093ebc517a642aaf21f3c7241c67657/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb#L115-L119 The regression #36132 is caused due to #35920 changed the enrollment order that the first action's record will be enrolled to last in the transaction. We could not change the the enrollment order as long as someone depends on the enrollment order. Fixes #36132.
Diffstat (limited to 'activerecord/test/cases/transaction_callbacks_test.rb')
-rw-r--r--activerecord/test/cases/transaction_callbacks_test.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/activerecord/test/cases/transaction_callbacks_test.rb b/activerecord/test/cases/transaction_callbacks_test.rb
index 53fe31e087..135e2cb382 100644
--- a/activerecord/test/cases/transaction_callbacks_test.rb
+++ b/activerecord/test/cases/transaction_callbacks_test.rb
@@ -36,6 +36,8 @@ class TransactionCallbacksTest < ActiveRecord::TestCase
has_many :replies, class_name: "ReplyWithCallbacks", foreign_key: "parent_id"
+ before_destroy { self.class.find(id).touch if persisted? }
+
before_commit { |record| record.do_before_commit(nil) }
after_commit { |record| record.do_after_commit(nil) }
after_save_commit { |record| record.do_after_commit(:save) }