Sha256: 0fdc5dd562a22a225731a69f4fe84bdd5106037b2d1b04d2188238fe8e6efee0

Contents?: true

Size: 1.19 KB

Versions: 51

Compression:

Stored size: 1.19 KB

Contents

require File.join(File.dirname(__FILE__), '../test_helper')

class AssociationIndexingTest < Test::Unit::TestCase
  
  fixtures :categories, :books 
  
  # Testing the association indexing with has_many:
  # 
  # class Category < ActiveRecord::Base
  #   has_many :books
  #   acts_as_solr :include => [:books]
  # end
  # 
  # Note that some of the search terms below are from the 'books'
  # table, but get indexed as being a part of Category
  def test_search_on_fields_in_has_many_association
    ['thriller', 'novel', 'splinter', 'clancy', 'tom clancy thriller'].each do |term|
      assert_equal 1, Category.count_by_solr(term), "expected one result: #{term}"
    end
  end
  
  # Testing the association indexing with belongs_to:
  # 
  # class Book < ActiveRecord::Base
  #   belongs_to :category
  #   acts_as_solr :include => [:category]
  # end
  # 
  # Note that some of the search terms below are from the 'categories'
  # table, but get indexed as being a part of Book
  def test_search_on_fields_in_belongs_to_association
    ['splinter', 'clancy', 'tom clancy thriller', 'splinter novel'].each do |term|
      assert_equal 1, Book.count_by_solr(term), "expected one result: #{term}"
    end
  end

end

Version data entries

51 entries across 51 versions & 9 rubygems

Version Path
honkster-acts_as_solr-0.1.0 test/functional/association_indexing_test.rb
honkster-acts_as_solr-0.2.0 test/functional/association_indexing_test.rb
honkster-acts_as_solr-0.2.1 test/functional/association_indexing_test.rb
honkster-acts_as_solr-0.2.2 test/functional/association_indexing_test.rb
honkster-acts_as_solr-0.2.3 test/functional/association_indexing_test.rb
honkster-acts_as_solr-0.2.4 test/functional/association_indexing_test.rb
honkster-acts_as_solr-0.2.5 test/functional/association_indexing_test.rb
honkster-acts_as_solr-0.3.4 test/functional/association_indexing_test.rb
jbasdf-acts_as_solr-0.3.3 test/functional/association_indexing_test.rb
jbasdf-jbasdf-acts_as_solr-0.4.0 test/functional/association_indexing_test.rb
jbasdf-muck-solr-0.4.0 test/functional/association_indexing_test.rb
jbasdf-muck-solr-0.4.1 test/functional/association_indexing_test.rb
jbasdf-muck-solr-0.4.2 test/functional/association_indexing_test.rb
onemorecloud-websolr-rails-1.1.1 test/functional/association_indexing_test.rb
onemorecloud-websolr-rails-1.3.3 test/functional/association_indexing_test.rb
onemorecloud-websolr-rails-1.4.0 test/functional/association_indexing_test.rb
onemorecloud-websolr-rails-1.4.1 test/functional/association_indexing_test.rb
acts_as_solr_reloaded-1.6.0 test/functional/association_indexing_test.rb
muck-solr-3.0.1 test/functional/association_indexing_test.rb
muck-solr-3.0.0 test/functional/association_indexing_test.rb