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

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

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 7.2.0.rc1
    • Associations
    • None
    • 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

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

              Dates

                Created:
                Updated:
                Resolved: