File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -290,14 +290,14 @@ def any?
290
290
# Returns true if there is exactly one record.
291
291
def one?
292
292
return super if block_given?
293
- return records . one? if limit_value || loaded?
293
+ return records . one? if loaded?
294
294
limited_count == 1
295
295
end
296
296
297
297
# Returns true if there is more than one record.
298
298
def many?
299
299
return super if block_given?
300
- return records . many? if limit_value || loaded?
300
+ return records . many? if loaded?
301
301
limited_count > 1
302
302
end
303
303
@@ -974,7 +974,7 @@ def tables_in_string(string)
974
974
end
975
975
976
976
def limited_count
977
- @limited_count ||= limit ( 2 ) . count
977
+ @limited_count ||= limit_value ? count : limit ( 2 ) . count
978
978
end
979
979
end
980
980
end
Original file line number Diff line number Diff line change @@ -1174,10 +1174,14 @@ def test_many
1174
1174
end
1175
1175
1176
1176
def test_many_with_limits
1177
- posts = Post . all
1177
+ posts_with_limit = Post . limit ( 5 )
1178
+ posts_with_limit_one = Post . limit ( 1 )
1178
1179
1179
- assert_predicate posts , :many?
1180
- assert_not_predicate posts . limit ( 1 ) , :many?
1180
+ assert_predicate posts_with_limit , :many?
1181
+ assert_not_predicate posts_with_limit , :loaded?
1182
+
1183
+ assert_not_predicate posts_with_limit_one , :many?
1184
+ assert_not_predicate posts_with_limit_one , :loaded?
1181
1185
end
1182
1186
1183
1187
def test_none?
You can’t perform that action at this time.
0 commit comments