mongoid/mongoid — Issue #1431: foo.bars.length != foo.bars.to_a.length
Author: sandstrom
Created: 2011-11-16 15:04:23+00:00
State: open

I've run into a bug where mother.children.length != mother.children.to_a.length in certain situations. A test-case built from a fresh rails-repository is referenced below.

TO REPRODUCE:
1. Setup a mother with associated children
2. call mother.children.any?
3. watch how mother.children.length != mother.children.to_a.length

The problem is related to
Mongoid::Relations::Targets::Enumerable

TEST-CASE:
# Let me know if I should elaborate on how to reproduce the bug. Aren't that many files though, so shouldn't be too hard to figure it out.
https://github.com/sandstrom/Mongoid-Bug