File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -1234,4 +1234,23 @@ def test_automatically_added_order_references
1234
1234
scope = Post . order ( 'foo(comments.body)' )
1235
1235
assert_equal [ ] , scope . references_values
1236
1236
end
1237
+
1238
+ def test_presence
1239
+ topics = Topic . scoped
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
1253
+
1254
+ assert topics . loaded?
1255
+ end
1237
1256
end
You can’t perform that action at this time.
0 commit comments