diff --git a/app/models/article.rb b/app/models/article.rb index 19be54c..7be9b86 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -21,7 +21,7 @@ class Article < ActiveRecord::Base acts_as_versioned - acts_as_searchable :fields => [ :name, :abstract, :body, :tag_list ] + acts_as_searchable before_update do |article| article.advertise = true diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index e7ebfdf..5a267f0 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -9,7 +9,7 @@ class Enterprise < Organization extra_data_for_index :product_categories def product_categories - products.map{|p| p.product_category.full_name.split('/') }.join(' ') + products.map{|p| p.product_category.full_name(' ') }.join(' ') end end diff --git a/app/models/profile.rb b/app/models/profile.rb index dd456f3..ca607e7 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -37,7 +37,7 @@ class Profile < ActiveRecord::Base acts_as_having_boxes - acts_as_searchable :fields => [ :name, :identifier, :extra_data_for_index ] + acts_as_searchable :additional_fields => [ :extra_data_for_index ] class_inheritable_accessor :extra_index_methods self.extra_index_methods = [] diff --git a/test/unit/product_test.rb b/test/unit/product_test.rb index 09287f5..cc3d232 100644 --- a/test/unit/product_test.rb +++ b/test/unit/product_test.rb @@ -67,4 +67,21 @@ class ProductTest < Test::Unit::TestCase assert_not_includes list, p3 end + should 'calculate catagory full name' do + cat = mock + cat.expects(:full_name).returns('A B C') + + p = Product.new + p.expects(:product_category).returns(cat) + assert_equal 'A B C', p.category_full_name + end + + should 'be indexed by category full name' do + p = Product.new(:name => 'a test product') + p.expects(:category_full_name).returns('interesting category') + p.save! + + assert_includes Product.find_by_contents('interesting'), p + end + end -- libgit2 0.21.2