Sha256: 9c6596faf6564f871a9d61cb89d70168affc693cc40599c61de0307ef633f76c

Contents?: true

Size: 889 Bytes

Versions: 1

Compression:

Stored size: 889 Bytes

Contents

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

describe 'searchable with lifecycle' do
  integrate_sunspot
  
  describe 'on create' do
    before :each do
      @post = PostWithAuto.create
      Sunspot.commit
    end

    it 'should automatically index' do
      PostWithAuto.search.results.should == [@post]
    end
  end

  describe 'on update' do
    before :each do
      @post = PostWithAuto.create
      @post.update_attributes(:title => 'Test 1')
      Sunspot.commit
    end

    it 'should automatically update index' do
      PostWithAuto.search { with :title, 'Test 1' }.results.should == [@post]
    end
  end

  describe 'on destroy' do
    before :each do
      @post = PostWithAuto.create
      @post.destroy
      Sunspot.commit
    end

    it 'should automatically remove it from the index' do
      PostWithAuto.search_ids.should be_empty
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
benjaminkrause-sunspot_rails-0.10.5 spec/model_lifecycle_spec.rb