Sha256: 2d1071dccbd488b335dea20e6c27a423578bdd55f0032b6ffbc43dca4ef2ffba

Contents?: true

Size: 1.1 KB

Versions: 14

Compression:

Stored size: 1.1 KB

Contents

require File.join(File.dirname(__FILE__), 'spec_helper')

describe 'search with dynamic fields' do
  it 'returns dynamic string facet' do
    stub_facet(:"custom_string:test_ss", 'two' => 2, 'one' => 1)
    result = session.search(Post) { dynamic(:custom_string) { facet(:test) }}
    result.facet(:custom_string, :test).rows.map { |row| row.value }.should == ['two', 'one']
  end

  it 'returns dynamic field facet with custom label' do
    stub_facet(:"bogus", 'two' => 2, 'one' => 1)
    result = session.search(Post) { dynamic(:custom_string) { facet(:test, :name => :bogus) }}
    result.facet(:bogus).rows.map { |row| row.value }.should == ['two', 'one']
  end

  it 'returns query facet specified in dynamic call' do
    stub_query_facet(
      'custom_string\:test_ss:(foo OR bar)' => 3
    )
    search = session.search(Post) do
      dynamic :custom_string do
        facet :test do
          row :foo_bar do
            with :test, %w(foo bar)
          end
        end
      end
    end
    facet = search.facet(:test)
    facet.rows.first.value.should == :foo_bar
    facet.rows.first.count.should == 3
  end
end

Version data entries

14 entries across 14 versions & 5 rubygems

Version Path
erichummel-sunspot-1.2.1g spec/api/search/dynamic_fields_spec.rb
erichummel-sunspot-1.2.1f spec/api/search/dynamic_fields_spec.rb
erichummel-sunspot-1.2.1b spec/api/search/dynamic_fields_spec.rb
erichummel-sunspot-1.2.1a spec/api/search/dynamic_fields_spec.rb
lisausa-sunspot-1.2.1.1 spec/api/search/dynamic_fields_spec.rb
ruben-sunspot-1.1.4 spec/api/search/dynamic_fields_spec.rb
ruben-sunspot-1.1.3 spec/api/search/dynamic_fields_spec.rb
ruben-sunspot-1.1.2 spec/api/search/dynamic_fields_spec.rb
sunspot-1.2.1 spec/api/search/dynamic_fields_spec.rb
sunspot-1.2.0 spec/api/search/dynamic_fields_spec.rb
ruben-sunspot-1.1.1 spec/api/search/dynamic_fields_spec.rb
ruben-sunspot-1.1.0 spec/api/search/dynamic_fields_spec.rb
nuatt_sunspot-1.1.0.3 spec/api/search/dynamic_fields_spec.rb
sunspot-1.1.0 spec/api/search/dynamic_fields_spec.rb