diff options
Diffstat (limited to 'vendor/plugins/thinking-sphinx/features/support/post_database.rb')
| -rw-r--r-- | vendor/plugins/thinking-sphinx/features/support/post_database.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/vendor/plugins/thinking-sphinx/features/support/post_database.rb b/vendor/plugins/thinking-sphinx/features/support/post_database.rb new file mode 100644 index 0000000..51cefb5 --- /dev/null +++ b/vendor/plugins/thinking-sphinx/features/support/post_database.rb | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | $:.unshift File.dirname(__FILE__) + '/../../lib' | ||
| 2 | |||
| 3 | require 'lib/thinking_sphinx' | ||
| 4 | |||
| 5 | %w( tmp/config tmp/log tmp/db/sphinx/development ).each do |path| | ||
| 6 | FileUtils.mkdir_p "#{Dir.pwd}/#{path}" | ||
| 7 | end | ||
| 8 | |||
| 9 | Kernel.const_set :RAILS_ROOT, "#{Dir.pwd}/tmp" unless defined?(RAILS_ROOT) | ||
| 10 | |||
| 11 | at_exit do | ||
| 12 | ThinkingSphinx::Configuration.instance.controller.stop | ||
| 13 | sleep(1) # Ensure Sphinx has shut down completely | ||
| 14 | FileUtils.rm_r "#{Dir.pwd}/tmp" | ||
| 15 | end | ||
| 16 | |||
| 17 | # Add log file | ||
| 18 | ActiveRecord::Base.logger = Logger.new open("tmp/active_record.log", "a") | ||
| 19 | |||
| 20 | ThinkingSphinx.deltas_enabled = false | ||
| 21 | |||
| 22 | # Load Models | ||
| 23 | Dir["features/support/models/*.rb"].sort.each do |file| | ||
| 24 | require file.gsub(/\.rb$/, '') | ||
| 25 | end | ||
| 26 | |||
| 27 | # Set up database tables and records | ||
| 28 | Dir["features/support/db/migrations/*.rb"].each do |file| | ||
| 29 | require file.gsub(/\.rb$/, '') | ||
| 30 | end | ||
| 31 | |||
| 32 | ThinkingSphinx.deltas_enabled = true | ||
| 33 | ThinkingSphinx.suppress_delta_output = true | ||
| 34 | |||
| 35 | ThinkingSphinx::Configuration.instance.build | ||
| 36 | ThinkingSphinx::Configuration.instance.controller.index | ||
| 37 | ThinkingSphinx::Configuration.instance.controller.start | ||
