Sha256: 54e546980be29c7ca8c3c1d58cc8588533c1d7ab6bf9ef61369aa3a13a1c33c4

Contents?: true

Size: 1.43 KB

Versions: 7

Compression:

Stored size: 1.43 KB

Contents

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

describe 'indexing fulltext fields' do
  it 'indexes text field' do
    session.index(post(:title => 'A Title'))
    expect(connection).to have_add_with(:title_text => 'A Title')
  end

  it 'indexes stored text field' do
    session.index(post(:body => 'Test body'))
    expect(connection).to have_add_with(:body_textsv => 'Test body')
  end

  it 'indexes text field with boost' do
    session.index(post(:title => 'A Title'))
    expect(connection.adds.last.first.field_by_name(:title_text).attrs[:boost]).to eq(2)
  end

  it 'indexes multiple values for a text field' do
    session.index(post(:body => %w(some title)))
    expect(connection).to have_add_with(:body_textsv => %w(some title))
  end

  it 'indexes text via a block accessor' do
    session.index(post(:title => 'backwards'))
    expect(connection).to have_add_with(:backwards_title_text => 'sdrawkcab')
  end

  it 'indexes document level boost using block' do
    session.index(post(:ratings_average => 4.0))
    expect(connection.adds.last.first.attrs[:boost]).to eq(1.25)
  end

  it 'indexes document level boost using attribute' do
    session.index(Namespaced::Comment.new(:boost => 1.5))
    expect(connection.adds.last.first.attrs[:boost]).to eq(1.5)
  end

  it 'indexes document level boost defined statically' do
    session.index(Photo.new)
    expect(connection.adds.last.first.attrs[:boost]).to eq(0.75)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

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