Sha256: 30b23f2dede31ca5808789474678caa0f7d742331b5711c24a4a5219635f4fc0

Contents?: true

Size: 1.44 KB

Versions: 19

Compression:

Stored size: 1.44 KB

Contents

module Ddr::Index
  RSpec.describe Filter do

    describe "#where(conditions)" do
      it "should add raw query filters for the field, value hash of conditions" do
        subject.where("foo"=>"bar", "spam"=>"eggs", "stuff"=>["dog", "cat", "bird"])
        expect(subject.clauses).to eq(["{!term f=foo}bar", "{!term f=spam}eggs", "stuff:(dog OR cat OR bird)"])
      end
    end

    describe "#raw(*clauses)" do
      it "should add the clauses w/o escaping" do
        subject.raw("foo:bar", "spam:eggs")
        expect(subject.clauses).to eq(["foo:bar", "spam:eggs"])
      end
    end

    describe "#present(field)" do
      it "should add a \"field present\" clause" do
        subject.present("foo")
        expect(subject.clauses).to eq(["foo:[* TO *]"])
      end
    end

    describe "#absent(field)" do
      it "should add a \"field not present\" clause" do
        subject.absent("foo")
        expect(subject.clauses).to eq(["-foo:[* TO *]"])
      end
    end

    describe "#before_days(field, days)" do
      it "should add a date range query clause" do
        subject.before_days("foo", 60)
        expect(subject.clauses).to eq(["foo:[* TO NOW-60DAYS]"])
      end
    end

    describe "#before(field, date_time)" do
      it "should add a date range query clause" do
        subject.before("foo", DateTime.parse("Thu, 27 Aug 2015 17:42:34 -0400"))
        expect(subject.clauses).to eq(["foo:[* TO 2015-08-27T21:42:34Z]"])
      end
    end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
ddr-models-3.0.0.beta.3 spec/index/filter_spec.rb
ddr-models-3.0.0.beta.2 spec/index/filter_spec.rb
ddr-models-2.4.0.rc2 spec/index/filter_spec.rb
ddr-models-2.4.0.rc1 spec/index/filter_spec.rb
ddr-models-2.3.2 spec/index/filter_spec.rb
ddr-models-3.0.0.beta.1 spec/index/filter_spec.rb
ddr-models-2.3.1 spec/index/filter_spec.rb
ddr-models-3.0.0.alpha.4 spec/index/filter_spec.rb
ddr-models-3.0.0.alpha.3 spec/index/filter_spec.rb
ddr-models-2.3.0 spec/index/filter_spec.rb
ddr-models-3.0.0.alpha.2 spec/index/filter_spec.rb
ddr-models-3.0.0.alpha.1 spec/index/filter_spec.rb
ddr-models-2.2.0 spec/index/filter_spec.rb
ddr-models-2.1.3 spec/index/filter_spec.rb
ddr-models-2.1.2 spec/index/filter_spec.rb
ddr-models-2.1.1 spec/index/filter_spec.rb
ddr-models-2.1.0 spec/index/filter_spec.rb
ddr-models-2.1.0.rc2 spec/index/filter_spec.rb
ddr-models-2.1.0.rc1 spec/index/filter_spec.rb