Sha256: ef0d2234708dd823cd8c2f21f149c498540e18d06ca3f90720a9c031f8508c52

Contents?: true

Size: 1.24 KB

Versions: 16

Compression:

Stored size: 1.24 KB

Contents

require 'spec_helper'
require 'multi_solr/utils'

describe MultiSolr::SolrFilterRange do

  subject{ MultiSolr::SolrFilterRange.new('test') }

  context 'render_value' do
    it "should return '>= 10' if value from is 10" do
      subject.render_value('from' => 10).should == 'von 10'
    end

    it "should return '<= 20' if value to is 20" do
      subject.render_value('to' => 20).should == 'bis 20'
    end

    it "should return '>=10 und <= 20' if value from is 10 and to is 20" do
      subject.render_value('from' => 10, 'to' => 20).should == 'von 10 bis 20'
    end

    it "should return empty string if no value given" do
      subject.render_value(nil).should == ''
      subject.render_value({}).should == ''
    end

  end

  context 'build_solr_query' do
    it do
      subject.build_solr_query('from' => 10).should == 'test:[10 TO *]'
    end

    it do
      subject.build_solr_query('from' => 10, 'to' => '').should == 'test:[10 TO *]'
    end

    it do
      subject.build_solr_query('to' => 20).should == 'test:[* TO 20]'
    end

    it do
      subject.build_solr_query('from' => '', 'to' => 20).should == 'test:[* TO 20]'
    end

    it do
      subject.build_solr_query('from' => 10, 'to' => 20).should == 'test:[10 TO 20]'
    end
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
multi-solr-01.12.00 spec/multi_solr/solr_filter_range_spec.rb
multi-solr-01.11.01 spec/multi_solr/solr_filter_range_spec.rb
multi-solr-01.11.00 spec/multi_solr/solr_filter_range_spec.rb
multi-solr-01.10.00 spec/multi_solr/solr_filter_range_spec.rb
multi-solr-01.09.05 spec/multi_solr/solr_filter_range_spec.rb
multi-solr-01.09.04 spec/multi_solr/solr_filter_range_spec.rb
multi-solr-01.09.03 spec/multi_solr/solr_filter_range_spec.rb
multi-solr-01.09.02 spec/multi_solr/solr_filter_range_spec.rb
multi-solr-01.09.01 spec/multi_solr/solr_filter_range_spec.rb
multi-solr-01.09.00 spec/multi_solr/solr_filter_range_spec.rb
multi-solr-01.08.01 spec/multi_solr/solr_filter_range_spec.rb
multi-solr-01.08.00 spec/multi_solr/solr_filter_range_spec.rb
multi-solr-01.07.07 spec/multi_solr/solr_filter_range_spec.rb
multi-solr-01.07.06 spec/multi_solr/solr_filter_range_spec.rb
multi-solr-01.07.05 spec/multi_solr/solr_filter_range_spec.rb
multi-solr-01.07.04 spec/multi_solr/solr_filter_range_spec.rb