aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2012-05-18 20:48:11 +0100
committerJon Leighton <j@jonathanleighton.com>2012-05-18 20:55:12 +0100
commitb98d1e21635d8776de8893cc09bd86c71f6c78f0 (patch)
treee2b3a7fe3982e4ae4cfaa718a9165d4f3243d9b7 /activerecord/test/cases/associations
parent2802ad0f72cd030efc3c4ec4f033389564609cec (diff)
downloadrails-b98d1e21635d8776de8893cc09bd86c71f6c78f0.tar.gz
rails-b98d1e21635d8776de8893cc09bd86c71f6c78f0.tar.bz2
rails-b98d1e21635d8776de8893cc09bd86c71f6c78f0.zip
Perf: Don't load the association for #delete_all.
Bug #6289 Conflicts: activerecord/test/cases/associations/has_many_associations_test.rb
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index a28b8e6651..c128ede34f 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -1698,4 +1698,16 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert_equal [bulb1, bulb3], car.bulbs
assert_equal [bulb1, bulb3], result
end
+
+ test "delete_all, when not loaded, doesn't load the records" do
+ post = posts(:welcome)
+
+ assert post.taggings_with_delete_all.count > 0
+ assert !post.taggings_with_delete_all.loaded?
+
+ # 2 queries: one DELETE and another to update the counter cache
+ assert_queries(2) do
+ post.taggings_with_delete_all.delete_all
+ end
+ end
end