-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
ruby require 'spec_helper' class Collection include Mongoid::Document embeds_many :things end class Thing include Mongoid::Document field :index field :name embedded_in :collection end describe Mongoid do it "inserts null records" do c = Collection.create! 11.times do |i| c.things << Thing.new(index: i, name: "t#{i}")\ end c.things.where({ :index.gt => 9 }).each do |thing| thing.update_attributes!({ index: thing.index - 1 }) end c.reload.things.count.should == 11 end end
Uh oh.
1) Mongoid inserts null records
Failure/Error: c.reload.things.count.should == 11
expected: 11
got: 101 (using ==)
It's making queries with a positional operator $0, then $1, above 10.