Sha256: 6b62284424791979ebbb87f24b1dc02d95a9f446d281d79b82bf8fa5764f9e2f

Contents?: true

Size: 1.65 KB

Versions: 32

Compression:

Stored size: 1.65 KB

Contents

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

describe 'document removal', :type => :indexer do
  it 'removes an object from the index' do
    session.remove(post)
    connection.should have_delete("Post #{post.id}")
  end

  it 'removes an object by type and id' do
    session.remove_by_id(Post, 1)
    connection.should have_delete('Post 1')
  end

  it 'removes an object by type and id and immediately commits' do
    connection.should_receive(:delete_by_id).with(['Post 1']).ordered
    connection.should_receive(:commit).ordered
    session.remove_by_id!(Post, 1)
  end

  it 'removes an object from the index and immediately commits' do
    connection.should_receive(:delete_by_id).ordered
    connection.should_receive(:commit).ordered
    session.remove!(post)
  end

  it 'removes everything from the index' do
    session.remove_all
    connection.should have_delete_by_query("*:*")
  end

  it 'removes everything from the index and immediately commits' do
    connection.should_receive(:delete_by_query).ordered
    connection.should_receive(:commit).ordered
    session.remove_all!
  end

  it 'removes everything of a given class from the index' do
    session.remove_all(Post)
    connection.should have_delete_by_query("type:Post")
  end

  it 'correctly escapes namespaced classes when removing everything from the index' do
    connection.should_receive(:delete_by_query).with('type:Namespaced\:\:Comment')
    session.remove_all(Namespaced::Comment)
  end

  it 'should remove by query' do
    session.remove(Post) do
      with(:title, 'monkeys')
    end
    connection.should have_delete_by_query("(type:Post AND title_ss:monkeys)")
  end
end

Version data entries

32 entries across 32 versions & 9 rubygems

Version Path
sunspot-2.1.0 spec/api/indexer/removal_spec.rb
sunspot-2.0.0 spec/api/indexer/removal_spec.rb
sunspot-2.0.0.pre.130115 spec/api/indexer/removal_spec.rb
gojee-sunspot-2.0.5 spec/api/indexer/removal_spec.rb
sunspot-2.0.0.pre.120925 spec/api/indexer/removal_spec.rb
sunspot_solr-2.0.0.pre.120924 sunspot/spec/api/indexer/removal_spec.rb
sunspot_rails-2.0.0.pre.120924 sunspot/spec/api/indexer/removal_spec.rb
sunspot-2.0.0.pre.120924 sunspot/spec/api/indexer/removal_spec.rb
gojee-sunspot-2.0.4 spec/api/indexer/removal_spec.rb
gojee-sunspot-2.0.2 spec/api/indexer/removal_spec.rb
sunspot-2.0.0.pre.120720 spec/api/indexer/removal_spec.rb
sunspot-1.3.3 spec/api/indexer/removal_spec.rb
sunspot-1.3.2 spec/api/indexer/removal_spec.rb
sunspot-2.0.0.pre.120417 spec/api/indexer/removal_spec.rb
sunspot-2.0.0.pre.120415 spec/api/indexer/removal_spec.rb
sunspot-1.3.1 spec/api/indexer/removal_spec.rb
erichummel-sunspot-2.0.0.pre.111215d spec/api/indexer/removal_spec.rb
erichummel-sunspot-2.0.0.pre.111215c spec/api/indexer/removal_spec.rb
erichummel-sunspot-2.0.0.pre.111215b spec/api/indexer/removal_spec.rb
erichummel-sunspot-2.0.0.pre.111215a spec/api/indexer/removal_spec.rb