diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-09-27 23:17:40 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-09-27 23:17:40 +0900 |
commit | 1930d22936c3bfb883dd4b46173bb902db17bb50 (patch) | |
tree | 38a68b7c77e6d59f5cf8934f37d7a264b4b24bee /activerecord/test/cases/associations | |
parent | 688c27c8945b924c2f3ae42e86229336f85638b9 (diff) | |
download | rails-1930d22936c3bfb883dd4b46173bb902db17bb50.tar.gz rails-1930d22936c3bfb883dd4b46173bb902db17bb50.tar.bz2 rails-1930d22936c3bfb883dd4b46173bb902db17bb50.zip |
Avoid extra touch queries when counter cache is updated
Since counter cache handles touch option too.
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r-- | activerecord/test/cases/associations/belongs_to_associations_test.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/activerecord/test/cases/associations/belongs_to_associations_test.rb b/activerecord/test/cases/associations/belongs_to_associations_test.rb index 8b205f0b85..1fca1be181 100644 --- a/activerecord/test/cases/associations/belongs_to_associations_test.rb +++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb @@ -616,8 +616,10 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase debate.touch(time: time) debate2.touch(time: time) - reply.parent_title = "debate" - reply.save! + assert_queries(3) do + reply.parent_title = "debate" + reply.save! + end assert_operator debate.reload.updated_at, :>, time assert_operator debate2.reload.updated_at, :>, time @@ -625,8 +627,10 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase debate.touch(time: time) debate2.touch(time: time) - reply.topic_with_primary_key = debate2 - reply.save! + assert_queries(3) do + reply.topic_with_primary_key = debate2 + reply.save! + end assert_operator debate.reload.updated_at, :>, time assert_operator debate2.reload.updated_at, :>, time |