Commit ae3a5cc328186254a9b2dfae5ba5a8fcebf071ef
1 parent
6f0362a9
Exists in
master
and in
29 other branches
ActionItem501: fixed some test that has wrong interfaces and fixed the environme…
…nt_finder to propely fetch enterprises by its products categories git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2157 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
11 additions
and
11 deletions
Show diff stats
app/models/environment_finder.rb
... | ... | @@ -31,7 +31,7 @@ class EnvironmentFinder |
31 | 31 | # SECURITY no risk of SQL injection, since product_category_ids comes from trusted source |
32 | 32 | @environment.send(asset).find_by_contents(query, ferret_options, options.merge({:conditions => 'product_category_id in (%s)' % product_category_ids.join(',') })) |
33 | 33 | elsif product_category && asset == :enterprises |
34 | - @environment.send(asset).find_by_contents(query + " +extra_data_for_index:#{product_category.name}", ferret_options, options) | |
34 | + @environment.send(asset).find_by_contents(query, ferret_options, options.merge(:include => 'products', :conditions => "products.product_category_id in (#{product_category_ids})")) | |
35 | 35 | else |
36 | 36 | @environment.send(asset).find_by_contents(query, ferret_options, options) |
37 | 37 | end | ... | ... |
test/functional/search_controller_test.rb
... | ... | @@ -396,8 +396,8 @@ class SearchControllerTest < Test::Unit::TestCase |
396 | 396 | should 'list recent articles in the category' do |
397 | 397 | recent = [] |
398 | 398 | finger = CategoryFinder.new(@category) |
399 | - finger.expects(:recent).with(anything).at_least_once | |
400 | - finger.expects(:recent).with('articles').returns(recent) | |
399 | + finger.expects(:recent).with(any_parameters).at_least_once | |
400 | + finger.expects(:recent).with('articles', anything).returns(recent) | |
401 | 401 | CategoryFinder.expects(:new).with(@category).returns(finger) |
402 | 402 | |
403 | 403 | get :category_index, :category_path => [ 'my-category' ] |
... | ... | @@ -417,8 +417,8 @@ class SearchControllerTest < Test::Unit::TestCase |
417 | 417 | should 'list recently registered people in the category' do |
418 | 418 | recent_people = [] |
419 | 419 | finger = CategoryFinder.new(@category) |
420 | - finger.expects(:recent).with(anything).at_least_once | |
421 | - finger.expects(:recent).with('people').returns(recent_people) | |
420 | + finger.expects(:recent).with(any_parameters).at_least_once | |
421 | + finger.expects(:recent).with('people', kind_of(Integer)).returns(recent_people) | |
422 | 422 | CategoryFinder.expects(:new).with(@category).returns(finger) |
423 | 423 | |
424 | 424 | get :category_index, :category_path => [ 'my-category' ] |
... | ... | @@ -428,8 +428,8 @@ class SearchControllerTest < Test::Unit::TestCase |
428 | 428 | should 'list recently registered communities in the category' do |
429 | 429 | recent_communities = [] |
430 | 430 | finger = CategoryFinder.new(@category) |
431 | - finger.expects(:recent).with(anything).at_least_once | |
432 | - finger.expects(:recent).with('communities').returns(recent_communities) | |
431 | + finger.expects(:recent).with(any_parameters).at_least_once | |
432 | + finger.expects(:recent).with('communities', anything).returns(recent_communities) | |
433 | 433 | CategoryFinder.expects(:new).with(@category).returns(finger) |
434 | 434 | |
435 | 435 | get :category_index, :category_path => [ 'my-category' ] |
... | ... | @@ -439,8 +439,8 @@ class SearchControllerTest < Test::Unit::TestCase |
439 | 439 | should 'list recently registered enterprises in the category' do |
440 | 440 | recent_enterptises = [] |
441 | 441 | finger = CategoryFinder.new(@category) |
442 | - finger.expects(:recent).with(anything).at_least_once | |
443 | - finger.expects(:recent).with('enterprises').returns(recent_enterptises) | |
442 | + finger.expects(:recent).with(any_parameters).at_least_once | |
443 | + finger.expects(:recent).with('enterprises', anything).returns(recent_enterptises) | |
444 | 444 | CategoryFinder.expects(:new).with(@category).returns(finger) |
445 | 445 | |
446 | 446 | get :category_index, :category_path => [ 'my-category' ] |
... | ... | @@ -720,9 +720,9 @@ class SearchControllerTest < Test::Unit::TestCase |
720 | 720 | cat1 = ProductCategory.create!(:name => 'pc test 1', :environment => Environment.default) |
721 | 721 | cat2 = ProductCategory.create!(:name => 'pc test 2', :environment => Environment.default) |
722 | 722 | ent = Enterprise.create!(:name => 'test ent', :identifier => 'test_ent') |
723 | - | |
723 | + | |
724 | 724 | cat1.products.create!(:name => 'prod test 1', :enterprise => ent) |
725 | - | |
725 | + | |
726 | 726 | get :index, :find_in => 'enterprises', :query => 'test' |
727 | 727 | |
728 | 728 | assert_includes assigns(:categories_menu).map(&:first), cat1 | ... | ... |