Sha256: 4863aa0a2d62cec3b202ae31c1c5bc3b77819e7fd36a97a07c71166b6de2cae4

Contents?: true

Size: 999 Bytes

Versions: 9

Compression:

Stored size: 999 Bytes

Contents

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

describe 'indexing' do
  it 'should index non-multivalued field with newlines' do
    lambda do
      Sunspot.index!(Post.new(:title => "A\nTitle"))
    end.should_not raise_error
  end

  it 'should correctly remove by model instance' do
    post = Post.new(:title => 'test post')
    Sunspot.index!(post)
    Sunspot.remove!(post)
    Sunspot.search(Post) { with(:title, 'test post') }.results.should be_empty
  end

  it 'should correctly delete by ID' do
    post = Post.new(:title => 'test post')
    Sunspot.index!(post)
    Sunspot.remove_by_id!(Post, post.id)
    Sunspot.search(Post) { with(:title, 'test post') }.results.should be_empty
  end

  it 'removes documents by query' do
    Sunspot.remove_all!
    posts = [Post.new(:title => 'birds'), Post.new(:title => 'monkeys')]
    Sunspot.index!(posts)
    Sunspot.remove! do
      with(:title, 'birds')
    end
    Sunspot.search(Post).should have(2).results
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
sunspot-1.3.3 spec/integration/indexing_spec.rb
sunspot-1.3.2 spec/integration/indexing_spec.rb
sunspot-1.3.1 spec/integration/indexing_spec.rb
sunspot-2.0.0.pre.111215 spec/integration/indexing_spec.rb
cb_sunspot-2.0.0.pre.5 spec/integration/indexing_spec.rb
cb_sunspot-2.0.0.pre.3 spec/integration/indexing_spec.rb
cb_sunspot-2.0.0.pre3 spec/integration/indexing_spec.rb
sunspot-1.3.0 spec/integration/indexing_spec.rb
sunspot-1.3.0.rc6 spec/integration/indexing_spec.rb