Sha256: f265f84e4a2d430137b9b350170f52fea95bee0d636fd6771e0bb20f7ad25448

Contents?: true

Size: 1.13 KB

Versions: 7

Compression:

Stored size: 1.13 KB

Contents

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

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) }}
    expect(result.facet(:custom_string, :test).rows.map { |row| row.value }).to eq(['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) }}
    expect(result.facet(:bogus).rows.map { |row| row.value }).to eq(['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)
    expect(facet.rows.first.value).to eq(:foo_bar)
    expect(facet.rows.first.count).to eq(3)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sunspot-2.7.1 spec/api/search/dynamic_fields_spec.rb
sunspot-2.7.0 spec/api/search/dynamic_fields_spec.rb
sunspot-2.6.0 spec/api/search/dynamic_fields_spec.rb
sunspot-2.5.0 spec/api/search/dynamic_fields_spec.rb
sunspot-2.4.0 spec/api/search/dynamic_fields_spec.rb
sunspot-2.3.0 spec/api/search/dynamic_fields_spec.rb
sunspot-2.2.8 spec/api/search/dynamic_fields_spec.rb