diff options
author | Arthur Neves <arthurnn@gmail.com> | 2015-12-06 16:35:05 -0500 |
---|---|---|
committer | Arthur Neves <arthurnn@gmail.com> | 2015-12-06 16:53:00 -0500 |
commit | e7c48db509f1b712c2a72a3ff7f27e3e8b7b4868 (patch) | |
tree | 3c4038204f37e5cb296b4f980ef9e5b5b318a23c /activerecord/test/cases | |
parent | ff891616ac8a5c41f1fa2aba6c747d81f0782198 (diff) | |
download | rails-e7c48db509f1b712c2a72a3ff7f27e3e8b7b4868.tar.gz rails-e7c48db509f1b712c2a72a3ff7f27e3e8b7b4868.tar.bz2 rails-e7c48db509f1b712c2a72a3ff7f27e3e8b7b4868.zip |
Make sure we touch all the parents when touch_later.
The problem was that when saving an object, we would
call touch_later on the parent which wont be saved immediteally, and
it wont call any callbacks. That was working one level up because
we were calling touch, during the touch_later commit phase. However that still
didnt solve the problem when you have a 3+ levels of parents to be touched,
as calling touch would affect the parent, but it would be too late to run callbacks
on its grand-parent.
The solution for this, is instead, call touch_later upwards when the first
touch_later is called. So we make sure all the timestamps are updated without relying
on callbacks.
This also removed the hard dependency BelongsTo builder had with the TouchLater module.
So we can still have the old behaviour if TouchLater module is not included.
[fixes 5f5e6d924973003c105feb711cefdb726f312768]
[related #19324]
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/touch_later_test.rb | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/activerecord/test/cases/touch_later_test.rb b/activerecord/test/cases/touch_later_test.rb index 7058f4fbe2..07dbb4b8f8 100644 --- a/activerecord/test/cases/touch_later_test.rb +++ b/activerecord/test/cases/touch_later_test.rb @@ -95,8 +95,6 @@ class TouchLaterTest < ActiveRecord::TestCase end def test_touching_three_deep - skip "Pending from #19324" - previous_tree_updated_at = trees(:root).updated_at previous_grandparent_updated_at = nodes(:grandparent).updated_at previous_parent_updated_at = nodes(:parent_a).updated_at |