-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
For example I have three models: Parent -> Child1 -> Child2
Unable to find source-code formatter for language: `ruby. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
require "spec_helper" class Parent include Mongoid::Document embeds_many :childs, class_name: "Child1" end class Child1 include Mongoid::Document embedded_in :parent embeds_many :childs, class_name: "Child2" end class Child2 include Mongoid::Document field :age, type: Integer, default: 0 embedded_in :child, class_name: "Child1" end describe "Saving embedded document" do before :each do Parent.delete_all parent = Parent.create parent.childs << Child1.new 5.times do parent.childs.first.childs << Child2.new end end it "should not create childs for the 'root' model " do child = Parent.first.childs.first.childs.last child.age = 10 child.save Parent.first.childs.count.should eql 1 end end
`
In this test I tried change field of the last embedded document but in the result it also create (Child2.count - 1) empty documents of Child1 instance (in this example 4).
This bug is very unusual because ids of created objects increment on every load from db.
P.S. This bug only in last version 3.1.0 (in 3.0.18 all works fine)