Sha256: 42bcbef9b2410ba84dca45537a12688b726ba513df47d783e8b73b846fc97e5c

Contents?: true

Size: 940 Bytes

Versions: 9

Compression:

Stored size: 940 Bytes

Contents

#
# Put this in spec/support/
# Will use a sunspot stub session as default in all tests,
# but if you include the EnableSunspot module inside of a describe block
# it will index record and make them searchable inside of that block.
#

Sunspot.session = Sunspot::Rails::StubSessionProxy.new(Sunspot.session)

module EnableSunspot
  extend ActiveSupport::Concern

  included do
    before(:all) do
      Sunspot.session = Sunspot.session.original_session
    end

    after do
      Sunspot.remove_all! 
    end

    after(:all) do
      Sunspot.session = Sunspot::Rails::StubSessionProxy.new(Sunspot.session)
    end
  end
end

#
# Make sunspot index right away in test environment.
#
module Sunspot
  module Rails
    module Searchable
      module InstanceMethods
        def solr_index
          solr_index!
        end
        
        def solr_remove_from_index
          solr_remove_from_index!
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
erp_search-4.2.0 spec/support/enable_sunspot.rb
erp_search-4.0.0 spec/support/enable_sunspot.rb
erp_search-3.1.2 spec/support/enable_sunspot.rb
erp_search-3.1.1 spec/support/enable_sunspot.rb
erp_search-3.1.0 spec/support/enable_sunspot.rb
erp_search-3.0.4 spec/support/enable_sunspot.rb
erp_search-3.0.3 spec/support/enable_sunspot.rb
erp_search-3.0.2 spec/support/enable_sunspot.rb
erp_search-3.0.1 spec/support/enable_sunspot.rb