Sha256: f95f18217b5a04459193f2a27d4bc468f4062b06123d57be6085a185dad682a7

Contents?: true

Size: 1.58 KB

Versions: 5

Compression:

Stored size: 1.58 KB

Contents

require 'spec_helper'

describe "Tagalong Sunspot Support" do
  describe "#enable_sunspot" do
    it "registers ActiveRecord instance adapter" do
      Sunspot::Adapters::DataAccessor.stub(:register)
      Sunspot.stub(:setup)
      Sunspot::Adapters::InstanceAdapter.should_receive(:register).with(Sunspot::Rails::Adapters::ActiveRecordInstanceAdapter, ActiveRecord::Base)
      Tagalong.enable_sunspot
    end

    it "registers ActiveRecord data adapter"  do
      Sunspot::Adapters::InstanceAdapter.stub(:register)
      Sunspot.stub(:setup)
      Sunspot::Adapters::DataAccessor.should_receive(:register).with(Sunspot::Rails::Adapters::ActiveRecordDataAccessor, ActiveRecord::Base)
      Tagalong.enable_sunspot
    end
    
    it "sets up indexing of the Tagalong::TagalongTag by sunspot" do
      Sunspot::Adapters::InstanceAdapter.stub(:register)
      Sunspot::Adapters::DataAccessor.stub(:register)
      Sunspot.should_receive(:setup).with(Tagalong::TagalongTag)
      Tagalong.enable_sunspot
    end
  end

  describe "#sunspot_enabled" do
    it "return false if #enable_sunspot has NOT previously been called" do
      Tagalong::TagalongTag.stub(:searchable?).and_return(false)
      Tagalong.sunspot_enabled?.should be_false
    end

    it "returns true if #enable_sunspot has previously been called" do
      Tagalong.enable_sunspot
      Tagalong.sunspot_enabled?.should be_true
    end
  end

  describe "#reindex_sunspot" do
    it "reindexes the Sunspot solr index for the supported models" do
      Tagalong::TagalongTag.should_receive(:reindex)
      Tagalong.reindex_sunspot
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tagalong-0.1.4 spec/lib/tagalong/sunspot_spec.rb
tagalong-0.1.3 spec/lib/tagalong/sunspot_spec.rb
tagalong-0.1.2 spec/lib/tagalong/sunspot_spec.rb
tagalong-0.1.1 spec/lib/tagalong/sunspot_spec.rb
tagalong-0.1.0 spec/lib/tagalong/sunspot_spec.rb