Sha256: 1f273c1cf08059d360a27d74923a607755ebe03691d65fb6e1a7684d8f409055
Contents?: true
Size: 1.03 KB
Versions: 4
Compression:
Stored size: 1.03 KB
Contents
require "spec_helper" describe Mongoid::Commands::Delete do describe "#execute" do before do @collection = mock @document = stub(:collection => @collection, :id => "1", :_parent => false) end it "removes the document from its collection" do @collection.expects(:remove).with({ :_id => @document.id }) Mongoid::Commands::Delete.execute(@document) end it "sets the destroyed flag to true" do @collection.expects(:remove).with({ :_id => @document.id }).returns(true) @document.expects(:destroyed=).with(true) Mongoid::Commands::Delete.execute(@document) end context "when the document is embedded" do before do @parent = Person.new @address = Address.new(:street => "Genoa Pl") @parent.addresses << @address end it "removes the document from the parent attributes" do @parent.addresses.should == [@address] Mongoid::Commands::Delete.execute(@address) @parent.addresses.should be_empty end end end end
Version data entries
4 entries across 4 versions & 2 rubygems