Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-4947

#any? method with block given does not behave as per Enumerable

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.2.0.rc1
    • Affects Version/s: None
    • Component/s: Associations
    • None
    • Fully Compatible

      After these changes MONGOID-4890, we have #any? method, which has the wrong behavior:
       

      roles = user.roles.where(name: 'admin')
      
      user.roles.any? { |role| role == 'user' } # => true
      

      That happens because `#any?` method doesn't check block.

      We need to add

      return super if block_given?
      

      right after def any?

            Assignee:
            neil.shweky@mongodb.com Neil Shweky (Inactive)
            Reporter:
            gsevka@gmail.com Всеволод Аврамов
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: