Sha256: 4faebb2f701ab2db19010c38daf6d8eb57f30b6eb16ed5c4b767275a55701192

Contents?: true

Size: 712 Bytes

Versions: 15

Compression:

Stored size: 712 Bytes

Contents

require "spec_helper"

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

15 entries across 15 versions & 1 rubygems

Version Path
mongoid-0.10.4 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.10.3 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.10.2 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.10.1 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.10.0 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.9.12 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.9.11 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.9.10 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.9.9 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.9.8 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.9.7 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.9.6 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.9.5 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.9.4 spec/unit/mongoid/commands/destroy_spec.rb
mongoid-0.9.3 spec/unit/mongoid/commands/destroy_spec.rb