Sha256: 15e358a925b699bebe0b403d68dbe9fc1ea27222daab0c9d812bfcc95ebb5947

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

require 'test_unit_test_case'
require File.join(File.dirname(__FILE__), '..', 'lib', 'rsolr-ext')

class RSolrExtRequestTest < Test::Unit::TestCase
  
  test 'standard request' do
    solr_params = RSolr::Ext::Request.map(
      :page=>'2',
      :per_page=>'10',
      :phrases=>{:name=>'This is a phrase'},
      :filters=>['test', {:price=>(1..10)}],
      :phrase_filters=>{:manu=>['Apple']},
      :queries=>'ipod',
      :facets=>{:fields=>['cat', 'blah']},
      :spellcheck => true
    )
    assert_equal ["test", "price:[1 TO 10]", "manu:\"Apple\""], solr_params[:fq]
    assert_equal 10, solr_params[:start]
    assert_equal 10, solr_params[:rows]
    assert_equal "ipod name:\"This is a phrase\"", solr_params[:q]
    assert_equal ['cat', 'blah'], solr_params['facet.field']
    assert_equal true, solr_params[:facet]
  end
  
  test 'fq param using the phrase_filters mapping' do
    solr_params = RSolr::Ext::Request.map(
      :phrase_filters=>{:manu=>['Apple', 'ASG'], :color=>['red', 'blue']}
    )
    expected = {:fq=>["color:\"red\"", "color:\"blue\"", "manu:\"Apple\"", "manu:\"ASG\""]}
    assert expected, solr_params
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rsolr-ext-0.11.0 test/request_test.rb
rsolr-ext-0.9.6.5 test/request_test.rb
rsolr-ext-0.9.6.4 test/request_test.rb