Sha256: eea98068ad584cb4035deef9e424791e0e79633e49cd20af9c42087b47c8eee9
Contents?: true
Size: 1.57 KB
Versions: 2
Compression:
Stored size: 1.57 KB
Contents
require File.dirname(__FILE__) + '/spec_helper' describe 'searchable with lifecycle' do 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 it "should index model if relevant attribute changed" do @post = PostWithAuto.create! @post.title = 'new title' @post.should_receive :index @post.save! end it "should not index model if relevant attribute not changed" do @post = PostWithAuto.create! @post.updated_at = Date.tomorrow @post.should_not_receive :index @post.save! 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 describe 'searchable with lifecycle - ignoring specific attributes' do before(:each) do @post = PostWithAuto.create end it "should not reindex the object on an update_at change, because it is marked as to-ignore" do Sunspot.should_not_receive(:index).with(@post) @post.update_attribute :updated_at, 123.seconds.from_now end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sunspot_rails-1.0.1 | spec/model_lifecycle_spec.rb |
sunspot_rails-1.0.0 | spec/model_lifecycle_spec.rb |