spec/embedded_save_spec.rb in mongodoc-0.2.1 vs spec/embedded_save_spec.rb in mongodoc-0.2.2

- old
+ new

@@ -17,11 +17,16 @@ include MongoDoc::Document key :data end - let(:leaf) { LeafDoc.new } + let(:leaf) do + doc = LeafDoc.new + doc._id = 'id' + doc + end + let(:data) { 'data' } context "#save" do let(:root) { NestedDocsRoot.new(:nested_children => [NestedChild.new(:leaf => leaf)]) } @@ -89,15 +94,15 @@ context "with has_many, update_attributes" do let(:root) { NestedDocsRoot.new(:nested_children => [NestedChild.new(:leaf => leaf)]) } it "calls the root document's _naive_update_attributes with a full attribute path and not safe" do - root.should_receive(:_strict_update_attributes).with({'nested_children.0.leaf.data' => data}, false, 'nested_children.leaf._id' => leaf_id) + root.should_receive(:_strict_update_attributes).with({'nested_children.0.leaf.data' => data}, false, 'nested_children.0.leaf._id' => leaf_id) leaf.update_attributes(:data => data, :__strict__ => true) end it "(with bang!) calls the root document's _naive_update_attributes with a full attribute path and safe" do - root.should_receive(:_strict_update_attributes).with({'nested_children.0.leaf.data' => data}, true, 'nested_children.leaf._id' => leaf_id) + root.should_receive(:_strict_update_attributes).with({'nested_children.0.leaf.data' => data}, true, 'nested_children.0.leaf._id' => leaf_id) leaf.update_attributes!(:data => data, :__strict__ => true) end end end end