Sha256: 55298d924fc6a8ffdedb5ebc3fe9ac73f5ee64a8bbe2f1b45e5e205d3ea5a347

Contents?: true

Size: 1.23 KB

Versions: 17

Compression:

Stored size: 1.23 KB

Contents

require "spec_helper"

describe Mongoid::Criteria::Scopable do

  context "when the document is paranoid" do

    context "when calling a class method" do

      let(:criteria) do
        Fish.fresh
      end

      it "includes the deleted_at criteria in the selector" do
        expect(criteria.selector).to eq({
          "deleted_at" => nil, "fresh" => true
        })
      end
    end

    context "when chaining a class method to unscoped" do

      let(:criteria) do
        Fish.unscoped.fresh
      end

      it "does not include the deleted_at in the selector" do
        expect(criteria.selector).to eq({ "fresh" => true })
      end
    end

    context "when chaining a class method to deleted" do

      let(:criteria) do
        Fish.deleted.fresh
      end

      it "includes the deleted_at $ne criteria in the selector" do
        expect(criteria.selector).to eq({
          "deleted_at" => { "$ne" => nil }, "fresh" => true
        })
      end
    end

    context "when chaining a where to unscoped" do

      let(:criteria) do
        Fish.unscoped.where(fresh: true)
      end

      it "includes no default scoping information in the selector" do
        expect(criteria.selector).to eq({ "fresh" => true })
      end
    end
  end
end

Version data entries

17 entries across 11 versions & 3 rubygems

Version Path
mongoid_paranoia-0.4.0 spec/mongoid/scoping_spec.rb
mongoid_paranoia-0.3.0 spec/mongoid/scoping_spec.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/bundler/gems/mongoid-paranoia-83dc8de7b426/spec/mongoid/scoping_spec.rb
mongoid-paranoia-1.3.0 spec/mongoid/criteria/scopable_spec.rb
mongoid-paranoia-1.3.0 spec/mongoid/scoping_spec.rb
mongoid-paranoia-1.2.0 spec/mongoid/criteria/scopable_spec.rb
mongoid-paranoia-1.2.0 spec/mongoid/scoping_spec.rb
mongoid-paranoia-1.1.0 spec/mongoid/scoping_spec.rb
mongoid-paranoia-1.1.0 spec/mongoid/criteria/scopable_spec.rb
mongoid_paranoia-0.2.1 spec/mongoid/scoping_spec.rb
mongoid_paranoia-0.2.0 spec/mongoid/scoping_spec.rb
mongoid-paranoia-1.0.1 spec/mongoid/scoping_spec.rb
mongoid-paranoia-1.0.1 spec/mongoid/criteria/scopable_spec.rb
mongoid-paranoia-1.0.0 spec/mongoid/criteria/scopable_spec.rb
mongoid-paranoia-1.0.0 spec/mongoid/scoping_spec.rb
mongoid-paranoia-1.0.0.beta2 spec/mongoid/criteria/scopable_spec.rb
mongoid-paranoia-1.0.0.beta2 spec/mongoid/scoping_spec.rb