Sha256: f1638dc07c0412b39a8afd0eab7f03b17e5bc71cefff42f2b48096ec98aaa02f

Contents?: true

Size: 1.24 KB

Versions: 18

Compression:

Stored size: 1.24 KB

Contents

require "spec_helper"

describe Mongoid::Commands::DeleteAll do

  describe "#execute" do

    before do
      @doc = mock
      @docs = [@doc]
      @klass = stub(:name => "Person")
    end

    context "when conditions supplied" do

      before do
        @collection = mock
        @conditions = { :conditions => { :title => "Sir" } }
      end

      it "deletes each document that the criteria finds" do
        @klass.expects(:collection).returns(@collection)
        @collection.expects(:remove).with(@conditions[:conditions].merge(:_type => "Person"))
        Mongoid::Commands::DeleteAll.execute(@klass, @conditions)
      end

    end

    context "when no conditions supplied" do

      before do
        @collection = mock
      end

      it "drops the collection" do
        @klass.expects(:collection).returns(@collection)
        @collection.expects(:drop)
        Mongoid::Commands::DeleteAll.execute(@klass)
      end

    end

    context "when empty conditions supplied" do

      before do
        @collection = mock
      end

      it "drops the collection" do
        @klass.expects(:collection).returns(@collection)
        @collection.expects(:drop)
        Mongoid::Commands::DeleteAll.execute(@klass, {})
      end

    end

  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
mongoid-1.0.6 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-1.0.5 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-1.0.4 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-1.0.3 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-1.0.2 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-1.0.1 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-1.0.0 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-0.12.0 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-0.11.9 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-0.11.8 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-0.11.7 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-0.11.6 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-0.11.5 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-0.11.4 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-0.11.3 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-0.11.2 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-0.11.1 spec/unit/mongoid/commands/delete_all_spec.rb
mongoid-0.11.0 spec/unit/mongoid/commands/delete_all_spec.rb