File tree Expand file tree Collapse file tree 1 file changed +15
-12
lines changed Expand file tree Collapse file tree 1 file changed +15
-12
lines changed Original file line number Diff line number Diff line change @@ -1238,18 +1238,21 @@ def test_automatically_added_order_references
1238
1238
def test_presence
1239
1239
topics = Topic . scoped
1240
1240
1241
- assert_queries ( 1 ) do
1242
- #checking if there are topics is used before you actually display them,
1243
- #thus it shouldn't invoke an extra count query
1244
- assert topics . present?
1245
- assert !topics . blank?
1246
-
1247
- #shows count of topics and loops after loading the query should not trigger extra queries either
1248
- assert_no_queries { topics . size }
1249
- assert_no_queries { topics . count }
1250
- assert_no_queries { topics . length }
1251
- assert_no_queries { topics . each }
1252
- end
1241
+ # the fist query is triggered because there are no topics yet.
1242
+ assert_queries ( 1 ) { assert topics . present? }
1243
+
1244
+ # checking if there are topics is used before you actually display them,
1245
+ # thus it shouldn't invoke an extra count query.
1246
+ assert_no_queries { assert topics . present? }
1247
+ assert_no_queries { assert !topics . blank? }
1248
+
1249
+ # shows count of topics and loops after loading the query should not trigger extra queries either.
1250
+ assert_no_queries { topics . size }
1251
+ assert_no_queries { topics . length }
1252
+ assert_no_queries { topics . each }
1253
+
1254
+ # count always trigger the COUNT query.
1255
+ assert_queries ( 1 ) { topics . count }
1253
1256
1254
1257
assert topics . loaded?
1255
1258
end
You can’t perform that action at this time.
0 commit comments