Skip to content

Instantly share code, notes, and snippets.

@bartocc
Created August 17, 2010 16:34
Show Gist options
  • Save bartocc/530703 to your computer and use it in GitHub Desktop.
Save bartocc/530703 to your computer and use it in GitHub Desktop.
Before("~@search") do
Sunspot.session = Sunspot::Rails::StubSessionProxy.new(Sunspot.session)
end
# make sure that pickle calls #index! on our appropriate models
require File.join(File.dirname(__FILE__), 'pickle')
module Pickle
module Session
def create_model_with_sunspot(a_model_name, fields = nil)
result = create_model_without_sunspot(a_model_name, fields)
model = model(a_model_name)
model.index! if model.respond_to?(:index!)
result
end
alias_method_chain :create_model, :sunspot
end
end
# clean out the Solr index after each scenario
After do
Admin.remove_all_from_index!
Product.remove_all_from_index!
Country.remove_all_from_index!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment