aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/relations_test.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-03-16 17:05:35 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-03-16 17:05:35 -0300
commit404d785d29680d03d8a7f99de9d5986706c4c2a1 (patch)
tree0356af9110f50ee81a7d8259546b3909a03a6467 /activerecord/test/cases/relations_test.rb
parent090156adebb5c373e05a333f695b9cc7b4fe1905 (diff)
downloadrails-404d785d29680d03d8a7f99de9d5986706c4c2a1.tar.gz
rails-404d785d29680d03d8a7f99de9d5986706c4c2a1.tar.bz2
rails-404d785d29680d03d8a7f99de9d5986706c4c2a1.zip
Fix ActiveRecord::Relation#blank? tests
Diffstat (limited to 'activerecord/test/cases/relations_test.rb')
-rw-r--r--activerecord/test/cases/relations_test.rb27
1 files changed, 15 insertions, 12 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index 515f0b9d04..63d47f5162 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -1238,18 +1238,21 @@ class RelationTest < ActiveRecord::TestCase
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