Acts_As_Ferret Indexing on Model Reloads

written by mark on April 8th, 2008 @ 01:02 PM

I've been using spec_server to run tests as I develop and noticed that each time that my tests run it would take just a bit longer run. Right about the same time I was alerted by a file system error about a file being locked. It happened to be in the ferret indexing play yard where there were gobs of files.

No prob, I thought. I put a remove_dir routine in my spec helper and it cleared out the index files without a hitch. But my run times were still increasing.

So it appears that AAF likes to auto-index when its gets initialized and during development it gets reloaded often. There is a class method in AAF called disable_ferret but by the time I am able to use this method the indexing has already taken place.

For a short term hack I decided I wanted my tests to run faster so I dumped AAF while using spec_server which runs is test mode. I perform my testing on ferret during integration testing in a different mode so I don't need to worry about toggling this line off and on and worry about whether it will be there when it is released.

There is already ticket in the trac system for this. Till then here is what I've got.


  acts_as_ferret :fields => {...} unless RAILS_ENV == 'test'

Comments are closed