Sha256: cbecae09e6b8cd8fbccb11b1dfbbd5fe97b6472ba021fe11da19666b1aa9e97d

Contents?: true

Size: 1.69 KB

Versions: 18

Compression:

Stored size: 1.69 KB

Contents

require 'rubygems'
require 'test/unit'
require 'active_record'
require 'active_record/fixtures'

begin
  require 'active_support/test_case'
rescue
end

RAILS_ROOT = File.dirname(__FILE__) unless defined? RAILS_ROOT
RAILS_ENV  = 'test' unless defined? RAILS_ENV
ENV["RAILS_ENV"] = "test"
ENV["ACTS_AS_SOLR_TEST"] = "true"

require File.expand_path(File.dirname(__FILE__) + '/../lib/acts_as_solr')
require File.expand_path(File.dirname(__FILE__) + '/../config/solr_environment.rb')

# Load Models
models_dir = File.join(File.dirname( __FILE__ ), 'models')
require "#{models_dir}/book.rb"
Dir[ models_dir + '/*.rb'].each { |m| require m }

if defined?(ActiveSupport::TestCase)
  class ActiveSupport::TestCase
    include ActiveRecord::TestFixtures
    self.fixture_path = File.dirname(__FILE__) + "/fixtures/"
  end unless ActiveSupport::TestCase.respond_to?(:fixture_path=)
else
  Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/"
end

class Test::Unit::TestCase
  def self.fixtures(*table_names)
    fixture_path = defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase.fixture_path : Test::Unit::TestCase.fixture_path
    if block_given?
      Fixtures.create_fixtures(fixture_path, table_names) { yield }
    else
      Fixtures.create_fixtures(fixture_path, table_names)
    end
    table_names.each do |table_name|
      clear_from_solr(table_name)
      klass = instance_eval table_name.to_s.capitalize.singularize
      klass.find(:all).each{|content| content.solr_save}
    end
    
    clear_from_solr(:novels)
  end
  
  private
  def self.clear_from_solr(table_name)
    ActsAsSolr::Post.execute(Solr::Request::Delete.new(:query => "type_s:#{table_name.to_s.capitalize.singularize}"))
  end
end

Version data entries

18 entries across 18 versions & 5 rubygems

Version Path
honkster-acts_as_solr-0.3.4 test/test_helper.rb
jbasdf-acts_as_solr-0.3.3 test/test_helper.rb
jbasdf-jbasdf-acts_as_solr-0.4.0 test/test_helper.rb
jbasdf-muck-solr-0.4.0 test/test_helper.rb
jbasdf-muck-solr-0.4.1 test/test_helper.rb
jbasdf-muck-solr-0.4.2 test/test_helper.rb
muck-solr-3.0.1 test/test_helper.rb
muck-solr-3.0.0 test/test_helper.rb
muck-solr-0.4.7 test/test_helper.rb
muck-solr-0.4.6 test/test_helper.rb
honkster-acts_as_solr-0.3.7 test/test_helper.rb
honkster-acts_as_solr-0.3.6 test/test_helper.rb
muck-solr-0.4.5 test/test_helper.rb
muck-solr-0.4.4 test/test_helper.rb
muck-solr-0.4.3 test/test_helper.rb
muck-solr-0.4.1 test/test_helper.rb
muck-solr-0.4.2 test/test_helper.rb
muck-solr-0.4.0 test/test_helper.rb