Sha256: b4b82e11c36985cdefff6072b3e5104c91bfadb9e16c141098acd6a44d688803

Contents?: true

Size: 760 Bytes

Versions: 24

Compression:

Stored size: 760 Bytes

Contents

require File.join(File.dirname(__FILE__), "/../../../spec_helper.rb")

describe Mongoid::Commands::Destroy do

  describe "#execute" do

    before do
      @collection = stub_everything
      @document = stub(:run_callbacks => true,
                       :collection => @collection,
                       :id => "1")
    end

    it "runs the before and after destroy callbacks" do
      @document.expects(:run_callbacks).with(:before_destroy)
      @document.expects(:run_callbacks).with(:after_destroy)
      Mongoid::Commands::Destroy.execute(@document)
    end

    it "removes the document from its collection" do
      @collection.expects(:remove).with({ :_id => @document.id })
      Mongoid::Commands::Destroy.execute(@document)
    end

  end

end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
mongoid-0.6.4 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.6.3 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.6.2 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.6.1 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.6.0 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.5.11 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.5.10 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.5.9 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.5.8 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.5.7 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.5.6 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.5.5 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.5.4 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.5.3 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.5.2 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.5.1 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.5.0 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.4.8 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.4.7 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.4.5 spec/unit/mongoid/commands/destroy_spec.rb