mirror of https://github.com/rails/rails
Merge pull request #46448 from fatkodima/fix-many-additional-arguments
This commit is contained in:
commit
e5f3d69203
|
@ -144,8 +144,8 @@ module Enumerable
|
|||
def many?
|
||||
cnt = 0
|
||||
if block_given?
|
||||
any? do |element|
|
||||
cnt += 1 if yield element
|
||||
any? do |element, *args|
|
||||
cnt += 1 if yield element, *args
|
||||
cnt > 1
|
||||
end
|
||||
else
|
||||
|
|
|
@ -255,6 +255,7 @@ class EnumerableTests < ActiveSupport::TestCase
|
|||
assert_equal false, GenericEnumerable.new([ 2 ]).many? { |x| x > 1 }
|
||||
assert_equal false, GenericEnumerable.new([ 1, 2 ]).many? { |x| x > 1 }
|
||||
assert_equal true, GenericEnumerable.new([ 1, 2, 2 ]).many? { |x| x > 1 }
|
||||
assert_equal true, GenericEnumerable.new([ 1, 2, 3]).each_with_index.many? { |x, i| x == i + 1 }
|
||||
end
|
||||
|
||||
def test_many_iterates_only_on_what_is_needed
|
||||
|
|
Loading…
Reference in New Issue