Commit cc5dd7a0f919f3a9bd5075474174ece35fdf7a50

Authored by Daniela Feitosa
Committed by Antonio Terceiro
1 parent 6205e6c9

ActionItem932: Adding link to general context when in categories

app/helpers/application_helper.rb
... ... @@ -714,6 +714,13 @@ module ApplicationHelper
714 714 title
715 715 end
716 716  
  717 + def search_page_link_to_all(options={})
  718 + if options[:category]
  719 + title = "<div align='center'>" + _('In all categories') + "</div>"
  720 + link_to title, :action => 'assets', :asset => options[:asset], :category_path => []
  721 + end
  722 + end
  723 +
717 724 def template_stylesheet_tag
718 725 if profile.nil?
719 726 stylesheet_link_tag '/designs/templates/default/stylesheets/style.css'
... ...
app/views/search/articles.rhtml
... ... @@ -4,6 +4,9 @@
4 4 :region => @region ? @region.name : nil,
5 5 :distance => @radius } ) %>
6 6  
  7 +<%= search_page_link_to_all( { :asset => params[:asset],
  8 + :category => @category }) %>
  9 +
7 10 <%= render :partial => 'search_form', :locals => { :form_title => @query.blank? ? _('Search') : _("Refine your search"), :simple_search => true } %>
8 11  
9 12 <%# FIXME ARMENGUE %>
... ...
app/views/search/communities.rhtml
... ... @@ -4,6 +4,9 @@
4 4 :region => @region ? @region.name : nil,
5 5 :distance => @radius } ) %>
6 6  
  7 +<%= search_page_link_to_all( { :asset => params[:asset],
  8 + :category => @category }) %>
  9 +
7 10 <%= render :partial => 'search_form', :locals => { :form_title => @query.blank? ? _('Search') : _("Refine your search"), :simple_search => true } %>
8 11  
9 12 <%# FIXME ARMENGUE %>
... ...
app/views/search/enterprises.rhtml
... ... @@ -10,6 +10,9 @@
10 10 <h2><%=h (_('Within %s km from %s') % [@radius, @region.name]) %><h2>
11 11 <% end %>
12 12  
  13 +<%= search_page_link_to_all( { :asset => params[:asset],
  14 + :category => @category }) %>
  15 +
13 16 <%= render :partial => 'search_form', :locals => { :form_title => _("Refine your search"), :simple_search => true } %>
14 17  
15 18 <% if @categories_menu %>
... ...
app/views/search/people.rhtml
... ... @@ -4,6 +4,9 @@
4 4 :region => @region ? @region.name : nil,
5 5 :distance => @radius } ) %>
6 6  
  7 +<%= search_page_link_to_all( { :asset => params[:asset],
  8 + :category => @category }) %>
  9 +
7 10 <%= render :partial => 'search_form', :locals => { :form_title => @query.blank? ? _('Search') : _("Refine your search"), :simple_search => true } %>
8 11  
9 12 <%# FIXME ARMENGUE %>
... ...
app/views/search/products.rhtml
... ... @@ -4,6 +4,9 @@
4 4 :region => @region ? @region.name : nil,
5 5 :distance => @radius } ) %>
6 6  
  7 +<%= search_page_link_to_all( { :asset => params[:asset],
  8 + :category => @category }) %>
  9 +
7 10 <%= render :partial => 'search_form', :locals => { :form_title => _("Refine your search"), :simple_search => true } %>
8 11  
9 12 <% if @categories_menu %>
... ...
test/functional/search_controller_test.rb
... ... @@ -957,6 +957,21 @@ class SearchControllerTest &lt; Test::Unit::TestCase
957 957 assert_equal 20, assigns(:results)[:enterprises].total_entries
958 958 end
959 959  
  960 + should 'add link to list in all categories when in a category' do
  961 + ['people', 'enterprises', 'products', 'communities', 'articles'].each do |asset|
  962 + get :index, :asset => asset, :category_path => [ 'my-category' ]
  963 + assert_tag :tag => 'div', :content => 'In all categories'
  964 + end
  965 + end
  966 +
  967 + should 'not add link to list in all categories when not in a category' do
  968 + ['people', 'enterprises', 'products', 'communities', 'articles'].each do |asset|
  969 + get :index, :asset => asset
  970 + assert_no_tag :tag => 'div', :content => 'In all categories'
  971 + end
  972 + end
  973 +
  974 +
960 975 ##################################################################
961 976 ##################################################################
962 977  
... ...