aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_many_associations_test.rb
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:57:32 +0100
commit80f16946bb89ef37f5ee0cb6c4a4c643424521a6 (patch)
tree74abc95488663d76630d4ca7cc891afd7462062b /activerecord/test/cases/associations/has_many_associations_test.rb
parenta6dbc3fe7a504805572e634d39e37fd63ba7fd45 (diff)
downloadrails-80f16946bb89ef37f5ee0cb6c4a4c643424521a6.tar.gz
rails-80f16946bb89ef37f5ee0cb6c4a4c643424521a6.tar.bz2
rails-80f16946bb89ef37f5ee0cb6c4a4c643424521a6.zip
Perf: Don't load the association for #delete_all.
Bug #6289
Diffstat (limited to 'activerecord/test/cases/associations/has_many_associations_test.rb')
-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 5bd7ed5a1b..b51f4b0786 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -1614,4 +1614,16 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert_equal [client], firm.clients_of_firm
assert_equal [client], firm.reload.clients_of_firm
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