Sha256: 1faefa78a9e1fdda488e12c66f67dd2713ad61d4b53420bfa2498d684c4800a5
Contents?: true
Size: 1.6 KB
Versions: 26
Compression:
Stored size: 1.6 KB
Contents
require File.expand_path('spec_helper', File.dirname(__FILE__)) 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 :solr_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 :solr_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
26 entries across 26 versions & 8 rubygems