ruby on rails 4 - Sunspot reindexing during tests erase development indexing -
i'm working on search api uses sunspot indexing , rspec testing.
i have test search controller :
context 'when doing simple search', :type => :request let!(:instance_of_my_model) { create(:instance_of_my_model) } 'return correct results' mymodel.reindex # test code request end end for running tests, start lauching solr server :
rake sunspot:solr:start rails_env=test after running test, stop solr server , run again in development environnement. search don't work anymore.
it works again if reindex :
rake sunspot:reindex (~1 hour since have 10m+ entries)
why happening ?
for information, /config/sunspot.yml :
development: solr: hostname: localhost port: 8982 log_level: info test: solr: hostname: localhost port: 8981 log_level: warning
after searching, answer : reindex on sunspot rails tipped me of.
my sunspot.yml should have been :
development: solr: hostname: localhost port: 8982 log_level: info path: /solr/development test: solr: hostname: localhost port: 8981 log_level: warning path: /solr/test
Comments
Post a Comment