Skip to content
Browse files

Merge pull request #5475 from rafaelfranca/fix-build

Fix ActiveRecord::Relation#blank? tests
  • Loading branch information...
2 parents 090156a + 404d785 commit facf1e54f1c9a6e6d82c7eab982f93b45336d2aa @drogus drogus committed Mar 16, 2012
Showing with 15 additions and 12 deletions.
  1. +15 −12 activerecord/test/cases/relations_test.rb
View
27 activerecord/test/cases/relations_test.rb
@@ -1238,18 +1238,21 @@ def test_automatically_added_order_references
def test_presence
topics = Topic.scoped
- assert_queries(1) do
- #checking if there are topics is used before you actually display them,
- #thus it shouldn't invoke an extra count query
- assert topics.present?
- assert !topics.blank?
-
- #shows count of topics and loops after loading the query should not trigger extra queries either
- assert_no_queries { topics.size }
- assert_no_queries { topics.count }
- assert_no_queries { topics.length }
- assert_no_queries { topics.each }
- end
+ # the fist query is triggered because there are no topics yet.
+ assert_queries(1) { assert topics.present? }
+
+ # checking if there are topics is used before you actually display them,
+ # thus it shouldn't invoke an extra count query.
+ assert_no_queries { assert topics.present? }
+ assert_no_queries { assert !topics.blank? }
+
+ # shows count of topics and loops after loading the query should not trigger extra queries either.
+ assert_no_queries { topics.size }
+ assert_no_queries { topics.length }
+ assert_no_queries { topics.each }
+
+ # count always trigger the COUNT query.
+ assert_queries(1) { topics.count }
assert topics.loaded?
end

0 comments on commit facf1e5

Please sign in to comment.
Something went wrong with that request. Please try again.