Commit 46b6c370330ccdc58f478c24d45bc66c17057c19

Authored by MoisesMachado
1 parent 677c647d

ActionItem551: make see_all link to real asset

Make see_all link of most_commented_articles block in the category page
link to artcles asset insead of non-existent most_commented_articles
asset


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2300 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/views/search/_display_results.rhtml
... ... @@ -18,10 +18,19 @@
18 18 <%= @names[name] %>
19 19 </h3>
20 20 <% end %>
21   - <%= link_to( results.respond_to?(:total_entries) ? _('see all (%d)') % results.total_entries : _('see all...'),
22   - params.merge(:action => 'index',
23   - :asset => name ),
24   - :class => 'see-more' ) if @results.size > 1 %>
  21 + <%# FIXME: don't hardcode an asset like this %>
  22 + <% if name == :most_commented_articles %>
  23 + <%= link_to( results.respond_to?(:total_entries) ? _('see all (%d)') % results.total_entries : _('see all...'),
  24 + params.merge(:action => 'index',
  25 + :asset => 'articles' ),
  26 + :class => 'see-more' ) if @results.size > 1 %>
  27 +
  28 + <% else %>
  29 + <%= link_to( results.respond_to?(:total_entries) ? _('see all (%d)') % results.total_entries : _('see all...'),
  30 + params.merge(:action => 'index',
  31 + :asset => name ),
  32 + :class => 'see-more' ) if @results.size > 1 %>
  33 + <% end %>
25 34 <% end %>
26 35 <% partial = partial_for_class results.first.class %>
27 36 <div class="search-results-innerbox search-results-type-<%= partial %> <%= 'common-profile-list-block' if partial == 'profile' %>">
... ...
test/functional/search_controller_test.rb
... ... @@ -928,6 +928,17 @@ class SearchControllerTest &lt; Test::Unit::TestCase
928 928 assert_not_includes assigns(:results)[:products], p2
929 929 end
930 930  
  931 + should 'show link to article asset in the see all foot link of the most_commented_articles block in the category page' do
  932 + art = create_user('teste').person.articles.create!(:name => 'an article to be found')
  933 + most_commented = [art]
  934 + finder = CategoryFinder.new(@category)
  935 + finder.expects(:most_commented_articles).returns(most_commented)
  936 + CategoryFinder.expects(:new).with(@category).returns(finder)
  937 +
  938 + get :category_index, :category_path => [ 'my-category' ]
  939 + assert_tag :tag => 'div', :attributes => {:class => /search-results-most_commented_articles/} , :descendant => {:tag => 'a', :attributes => { :href => '/search/index/my-category?asset=articles'}}
  940 + end
  941 +
931 942 ##################################################################
932 943 ##################################################################
933 944  
... ...