aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-04-10 19:26:15 +0900
committerRyuta Kamizono <kamipo@gmail.com>2019-04-10 19:26:15 +0900
commitbcb0fb792735e1be08ccffb153654cfc886e5ff4 (patch)
treeddd3b03baac97a33e2a8ad320d4b9aad1c5574af /activerecord/test
parent5f261d04d6f857d49c75124df809adfbd6cd5b5e (diff)
downloadrails-bcb0fb792735e1be08ccffb153654cfc886e5ff4.tar.gz
rails-bcb0fb792735e1be08ccffb153654cfc886e5ff4.tar.bz2
rails-bcb0fb792735e1be08ccffb153654cfc886e5ff4.zip
Lazy sync with transaction state on destroy
This reverts commit 58410b3d566e6b93c7b71c0eec0fc11ec906b68e. If we have any implicit commit/rollback callbacks, it is necessary to add record to transaction explicitly like `:touch_deferred_attributes`. https://github.com/rails/rails/blob/5f261d04d6f857d49c75124df809adfbd6cd5b5e/activerecord/lib/active_record/touch_later.rb#L9 https://github.com/rails/rails/blob/5f261d04d6f857d49c75124df809adfbd6cd5b5e/activerecord/lib/active_record/touch_later.rb#L25 But I can't find any other implicit commit/rollback callbacks in our code base at least now. I think the `self.class.connection.add_transaction_record(self)` line doesn't cover any behavior.
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/transactions_test.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/activerecord/test/cases/transactions_test.rb b/activerecord/test/cases/transactions_test.rb
index 410f07d3ab..d5a4f12376 100644
--- a/activerecord/test/cases/transactions_test.rb
+++ b/activerecord/test/cases/transactions_test.rb
@@ -26,13 +26,15 @@ class TransactionTest < ActiveRecord::TestCase
def test_raise_after_destroy
assert_not_predicate @first, :frozen?
- assert_raises(RuntimeError) {
- Topic.transaction do
- @first.destroy
- assert_predicate @first, :frozen?
- raise
+ assert_not_called(@first, :rolledback!) do
+ assert_raises(RuntimeError) do
+ Topic.transaction do
+ @first.destroy
+ assert_predicate @first, :frozen?
+ raise
+ end
end
- }
+ end
assert_not_predicate @first, :frozen?
end