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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 7.2.0.rc1
    • Component/s: Associations
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible

      Description

      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?

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: