From 63fd88ca5c255a84b61ce81c41dfe9928ea101d9 Mon Sep 17 00:00:00 2001 From: David Verhasselt Date: Fri, 23 May 2014 13:46:03 +0300 Subject: If a counter_cache exists, use it for #empty? --- activerecord/test/cases/associations/has_many_associations_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'activerecord/test/cases/associations') diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index 5f01352ab4..a80be99720 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -807,6 +807,13 @@ class HasManyAssociationsTest < ActiveRecord::TestCase end end + def test_calling_empty_with_counter_cache + post = posts(:welcome) + assert_queries(0) do + assert_not post.comments.empty? + end + end + def test_custom_named_counter_cache topic = topics(:first) -- cgit v1.2.3 From c40bfc80b7e0a9c21f387652e9d1c01a6486a8e7 Mon Sep 17 00:00:00 2001 From: Zuhao Wan Date: Tue, 22 Jul 2014 17:03:26 +0800 Subject: Make sure assertion passes for postgresql. --- .../test/cases/associations/nested_through_associations_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/test/cases/associations') diff --git a/activerecord/test/cases/associations/nested_through_associations_test.rb b/activerecord/test/cases/associations/nested_through_associations_test.rb index 3720d6d251..31b68c940e 100644 --- a/activerecord/test/cases/associations/nested_through_associations_test.rb +++ b/activerecord/test/cases/associations/nested_through_associations_test.rb @@ -130,7 +130,7 @@ class NestedThroughAssociationsTest < ActiveRecord::TestCase def test_has_many_through_has_one_through_with_has_one_source_reflection_preload members = assert_queries(4) { Member.includes(:nested_sponsors).to_a } mustache = sponsors(:moustache_club_sponsor_for_groucho) - assert_no_queries do + assert_no_queries(ignore_none: false) do assert_equal [mustache], members.first.nested_sponsors end end -- cgit v1.2.3