Sha256: 9f2ec7d31f2dd2b575c1100c636bf1d173d4639b7474aa3e3f23bfaf857f1889

Contents?: true

Size: 1.42 KB

Versions: 18

Compression:

Stored size: 1.42 KB

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


  describe "in batches" do
    let(:post_1) { Post.new :title => 'A tittle' }
    let(:post_2) { Post.new :title => 'Another title' }

    describe "nested" do
      let(:a_nested_batch) do
        Sunspot.batch do
          Sunspot.index post_1

          Sunspot.batch do
            Sunspot.index post_2
          end
        end
      end

      it "does not fail" do
        expect { a_nested_batch }.to_not raise_error
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 5 rubygems

Version Path
sunspot-2.1.0 spec/integration/indexing_spec.rb
sunspot-2.0.0 spec/integration/indexing_spec.rb
sunspot-2.0.0.pre.130115 spec/integration/indexing_spec.rb
gojee-sunspot-2.0.5 spec/integration/indexing_spec.rb
sunspot-2.0.0.pre.120925 spec/integration/indexing_spec.rb
sunspot_solr-2.0.0.pre.120924 sunspot/spec/integration/indexing_spec.rb
sunspot_rails-2.0.0.pre.120924 sunspot/spec/integration/indexing_spec.rb
sunspot-2.0.0.pre.120924 sunspot/spec/integration/indexing_spec.rb
gojee-sunspot-2.0.4 spec/integration/indexing_spec.rb
gojee-sunspot-2.0.2 spec/integration/indexing_spec.rb
sunspot-2.0.0.pre.120720 spec/integration/indexing_spec.rb
sunspot-2.0.0.pre.120417 spec/integration/indexing_spec.rb
sunspot-2.0.0.pre.120415 spec/integration/indexing_spec.rb
erichummel-sunspot-2.0.0.pre.111215d spec/integration/indexing_spec.rb
erichummel-sunspot-2.0.0.pre.111215c spec/integration/indexing_spec.rb
erichummel-sunspot-2.0.0.pre.111215b spec/integration/indexing_spec.rb
erichummel-sunspot-2.0.0.pre.111215a spec/integration/indexing_spec.rb
erichummel-sunspot-2.0.0.pre.111215 spec/integration/indexing_spec.rb