diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-09-26 23:37:09 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-09-26 23:45:08 +0900 |
commit | a592e87a278cec10569d854dd5ece22179471bc0 (patch) | |
tree | e6806c20f83a43dac6126b360e91a554f6807424 /activerecord/test | |
parent | 52e11e462f6114a4d12225c639c5f501f0ffec7a (diff) | |
download | rails-a592e87a278cec10569d854dd5ece22179471bc0.tar.gz rails-a592e87a278cec10569d854dd5ece22179471bc0.tar.bz2 rails-a592e87a278cec10569d854dd5ece22179471bc0.zip |
Remove force parent loading when counter cache child is created/destroyed
`association.increment_counters` and `association.decrement_counters`
works regardless of parent target is loaded or not.
Related 52e11e462f6114a4d12225c639c5f501f0ffec7a.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/associations/belongs_to_associations_test.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/test/cases/associations/belongs_to_associations_test.rb b/activerecord/test/cases/associations/belongs_to_associations_test.rb index 43763dc715..8b205f0b85 100644 --- a/activerecord/test/cases/associations/belongs_to_associations_test.rb +++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb @@ -578,7 +578,11 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase def test_belongs_to_counter_after_save topic = Topic.create!(title: "monday night") - topic.replies.create!(title: "re: monday night", content: "football") + + assert_queries(2) do + topic.replies.create!(title: "re: monday night", content: "football") + end + assert_equal 1, Topic.find(topic.id)[:replies_count] topic.save! |