Commit e6d52bfcdff42a867d492e6082ade81ffc7c9626

Authored by AntonioTerceiro
1 parent a2ee8496

ActionItem352: taking a more aggresive approach on indexing



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1863 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/models/article.rb
... ... @@ -21,7 +21,7 @@ class Article < ActiveRecord::Base
21 21  
22 22 acts_as_versioned
23 23  
24   - acts_as_searchable :fields => [ :name, :abstract, :body, :tag_list ]
  24 + acts_as_searchable
25 25  
26 26 before_update do |article|
27 27 article.advertise = true
... ...
app/models/enterprise.rb
... ... @@ -9,7 +9,7 @@ class Enterprise < Organization
9 9 extra_data_for_index :product_categories
10 10  
11 11 def product_categories
12   - products.map{|p| p.product_category.full_name.split('/') }.join(' ')
  12 + products.map{|p| p.product_category.full_name(' ') }.join(' ')
13 13 end
14 14  
15 15 end
... ...
app/models/profile.rb
... ... @@ -37,7 +37,7 @@ class Profile < ActiveRecord::Base
37 37  
38 38 acts_as_having_boxes
39 39  
40   - acts_as_searchable :fields => [ :name, :identifier, :extra_data_for_index ]
  40 + acts_as_searchable :additional_fields => [ :extra_data_for_index ]
41 41  
42 42 class_inheritable_accessor :extra_index_methods
43 43 self.extra_index_methods = []
... ...
test/unit/product_test.rb
... ... @@ -67,4 +67,21 @@ class ProductTest < Test::Unit::TestCase
67 67 assert_not_includes list, p3
68 68 end
69 69  
  70 + should 'calculate catagory full name' do
  71 + cat = mock
  72 + cat.expects(:full_name).returns('A B C')
  73 +
  74 + p = Product.new
  75 + p.expects(:product_category).returns(cat)
  76 + assert_equal 'A B C', p.category_full_name
  77 + end
  78 +
  79 + should 'be indexed by category full name' do
  80 + p = Product.new(:name => 'a test product')
  81 + p.expects(:category_full_name).returns('interesting category')
  82 + p.save!
  83 +
  84 + assert_includes Product.find_by_contents('interesting'), p
  85 + end
  86 +
70 87 end
... ...