Commit e871103efc701308f227aeba20a38d8f6ba80c14

Authored by JoenioCosta
1 parent 19e1c26f

ActionItem346: list enterprises in category index

git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1774 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/public/search_controller.rb
... ... @@ -83,7 +83,8 @@ class SearchController < ApplicationController
83 83 [ :recent_communities, _('Recently created communities'), @finder.recent('communities') ],
84 84 [ :recent_articles, _('Recent articles'), @finder.recent('articles') ],
85 85 [ :comments, _('Recent comments'), @finder.recent('comments') ],
86   - [ :most_commented_articles, _('Most commented articles'), @finder.most_commented_articles ]
  86 + [ :most_commented_articles, _('Most commented articles'), @finder.most_commented_articles ],
  87 + [ :recent_enterptises, _('Recently created enterprises'), @finder.recent('enterprises') ]
87 88 ].each do |key, name, list|
88 89 @results[key] = list
89 90 @names[key] = name
... ...
test/functional/search_controller_test.rb
... ... @@ -422,7 +422,7 @@ class SearchControllerTest < Test::Unit::TestCase
422 422 assert_tag :tag => 'form' , :attributes => { :method => 'get' }
423 423 end
424 424  
425   - def test_should_display_a_given_category
  425 + should 'display a given category' do
426 426 get :category_index, :category_path => [ 'my-category' ]
427 427 assert_equal @category, assigns(:category)
428 428 end
... ... @@ -486,6 +486,17 @@ class SearchControllerTest < Test::Unit::TestCase
486 486 assert_same recent_communities, assigns(:results)[:recent_communities]
487 487 end
488 488  
  489 + should 'list recently registered enterprises in the category' do
  490 + recent_enterptises = []
  491 + finger = CategoryFinder.new(@category)
  492 + finger.expects(:recent).with(anything).at_least_once
  493 + finger.expects(:recent).with('enterprises').returns(recent_enterptises)
  494 + CategoryFinder.expects(:new).with(@category).returns(finger)
  495 +
  496 + get :category_index, :category_path => [ 'my-category' ]
  497 + assert_same recent_enterptises, assigns(:results)[:recent_enterptises]
  498 + end
  499 +
489 500 should 'not list "Search for ..." in category_index' do
490 501 get :category_index, :category_path => [ 'my-category' ]
491 502 assert_no_tag :content => /Search for ".*" in the whole site/
... ...