Commit a0b4958a6241aed730d9a2246c493768049967ca
1 parent
66eb23a5
Exists in
master
and in
28 other branches
ActionItem497: fixed
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2097 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
25 additions
and
1 deletions
Show diff stats
app/models/category_finder.rb
@@ -60,7 +60,7 @@ class CategoryFinder | @@ -60,7 +60,7 @@ class CategoryFinder | ||
60 | {:select => 'distinct comments.*', :joins => 'inner join articles_categories on articles_categories.article_id = comments.article_id', :conditions => ['articles_categories.category_id = (?)', category_id]}.merge!(options) | 60 | {:select => 'distinct comments.*', :joins => 'inner join articles_categories on articles_categories.article_id = comments.article_id', :conditions => ['articles_categories.category_id = (?)', category_id]}.merge!(options) |
61 | when 'Product' | 61 | when 'Product' |
62 | if prod_cat_ids | 62 | if prod_cat_ids |
63 | - {:joins => 'inner join categories_profiles on products.enterprise_id = categories_profiles.profile_id', :conditions => ['categories_profiles.category_id in (?) and products.product_category_id = (?)', category_id, prod_cat_ids]}.merge!(options) | 63 | + {:joins => 'inner join categories_profiles on products.enterprise_id = categories_profiles.profile_id', :conditions => ['categories_profiles.category_id = (?) and products.product_category_id in (?)', category_id, prod_cat_ids]}.merge!(options) |
64 | else | 64 | else |
65 | {:joins => 'inner join categories_profiles on products.enterprise_id = categories_profiles.profile_id', :conditions => ['categories_profiles.category_id = (?)', category_id]}.merge!(options) | 65 | {:joins => 'inner join categories_profiles on products.enterprise_id = categories_profiles.profile_id', :conditions => ['categories_profiles.category_id = (?)', category_id]}.merge!(options) |
66 | end | 66 | end |
test/functional/search_controller_test.rb
@@ -813,6 +813,30 @@ class SearchControllerTest < Test::Unit::TestCase | @@ -813,6 +813,30 @@ class SearchControllerTest < Test::Unit::TestCase | ||
813 | assert_equal 1, assigns(:counts)[cat2.id][1] | 813 | assert_equal 1, assigns(:counts)[cat2.id][1] |
814 | end | 814 | end |
815 | 815 | ||
816 | + should 'display only within a product category when specified' do | ||
817 | + prod_cat = ProductCategory.create!(:name => 'prod cat test', :environment => Environment.default) | ||
818 | + ent = Enterprise.create!(:name => 'test ent', :identifier => 'test_ent') | ||
819 | + | ||
820 | + p = prod_cat.products.create!(:name => 'prod test 1', :enterprise => ent) | ||
821 | + | ||
822 | + get :index, :find_in => 'products', :product_category => prod_cat.id | ||
823 | + | ||
824 | + assert_includes assigns(:results)[:products], p | ||
825 | + end | ||
826 | + | ||
827 | + should 'display properly in conjuntion with a category' do | ||
828 | + cat = Category.create(:name => 'cat', :environment => Environment.default) | ||
829 | + prod_cat1 = ProductCategory.create!(:name => 'prod cat test 1', :environment => Environment.default) | ||
830 | + prod_cat2 = ProductCategory.create!(:name => 'prod cat test 2', :environment => Environment.default, :parent => prod_cat1) | ||
831 | + ent = Enterprise.create!(:name => 'test ent', :identifier => 'test_ent', :category_ids => [cat.id]) | ||
832 | + | ||
833 | + p = prod_cat2.products.create!(:name => 'prod test 1', :enterprise => ent) | ||
834 | + | ||
835 | + get :index, :find_in => 'products', :category_path => cat.path.split('/'), :product_category => prod_cat1.id | ||
836 | + | ||
837 | + assert_includes assigns(:results)[:products], p | ||
838 | + end | ||
839 | + | ||
816 | should 'provide calendar for events' do | 840 | should 'provide calendar for events' do |
817 | get :index, :find_in => [ 'events' ] | 841 | get :index, :find_in => [ 'events' ] |
818 | assert_equal 0, assigns(:calendar).size % 7 | 842 | assert_equal 0, assigns(:calendar).size % 7 |