<%= link_to _('Search for "%s" in the whole site') % @query,
:controller => 'search', :action => 'index', :category_path => [], :query => @query %>
diff --git a/app/views/search/_product_category.rhtml b/app/views/search/_product_category.rhtml
deleted file mode 100644
index 1d9d887..0000000
--- a/app/views/search/_product_category.rhtml
+++ /dev/null
@@ -1,29 +0,0 @@
-<%= link_to(_('I consume this'), {:profile => current_user.login, :controller => 'consumed_products', :action => 'new', 'consumption[product_category_id]' => @category.id }, :method => :post) if logged_in? %>
-
- - <%= n_("One product in this category.", "%{num} products in this category.", @products.size) % { :num => @products.size } %>
- - <%= n_("One enterprise sells products in this category.", "%{num} enterprises sells products in this category.", @enterprises.size) % { :num => @enterprises.size} %>
- - <%= n_("One user consumes this product.", "%{num} users consumes this product", @users.size) % {:num => @users.size} %>
-
-
-
<%= _('Products under this category:') %>
-
- <% @products.each do |p| %>
- -
- <%= image_tag p.image.public_filename(:thumb) if p.image%>
- <%= link_to_product(p) %>
- <% if p.price %>
- <%= _('Price: %d') % p.price %>
- <% end %>
- <%= _('Enterprise:') %> <%= link_to_homepage p.enterprise.name, p.enterprise.identifier %>
-
- <% end %>
-
-
-
<%= _('Users that consumes products in this category:') %>
-
-<% @users.each do |u| %>
-
- <%= image_tag u.image.public_filename(:thumb) if u.image %>
- <%= link_to_homepage(u.name, u.identifier) %>
-
-<% end %>
diff --git a/app/views/search/_region.rhtml b/app/views/search/_region.rhtml
deleted file mode 120000
index 859d4d2..0000000
--- a/app/views/search/_region.rhtml
+++ /dev/null
@@ -1 +0,0 @@
-_category.rhtml
\ No newline at end of file
diff --git a/app/views/search/assets.rhtml b/app/views/search/assets.rhtml
index 260869b..dfa7cad 100644
--- a/app/views/search/assets.rhtml
+++ b/app/views/search/assets.rhtml
@@ -1,3 +1,3 @@
-
<%= @category ? (_('%{asset_name} in %{category}') % { :asset_name => @asset_name, :category => @category.full_name}) : @asset_name %>
+
<%= @category ? (_('%{asset_name} in %{category}') % { :asset_name => @asset_name, :category => @category.name}) : @asset_name %>
<%= render :partial => 'display_results' %>
diff --git a/app/views/search/category_index.rhtml b/app/views/search/category_index.rhtml
index f4222b1..edd7068 100644
--- a/app/views/search/category_index.rhtml
+++ b/app/views/search/category_index.rhtml
@@ -6,10 +6,8 @@
<%= _('Category: %s') % @category.name %>
-
- <%= render :partial => @category.class.name.underscore %>
-
-
+ <%= render :partial => 'display_results' %>
+
<%= _('Sub-categories') %>
<% if @category.children.empty? %>
diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb
index f66067b..6565e0f 100644
--- a/test/functional/search_controller_test.rb
+++ b/test/functional/search_controller_test.rb
@@ -433,46 +433,62 @@ class SearchControllerTest < Test::Unit::TestCase
end
should 'list recent articles in the category' do
- @controller.expects(:category).returns(@category).at_least_once
recent = []
- finder = CategoryFinder.new(@category)
- finder.expects(:recent).with('comments').returns(recent)
- finder.expects(:recent).with('articles').returns(recent)
- CategoryFinder.expects(:new).with(@category).returns(finder)
+ finger = CategoryFinder.new(@category)
+ finger.expects(:recent).with(anything).at_least_once
+ finger.expects(:recent).with('articles').returns(recent)
+ CategoryFinder.expects(:new).with(@category).returns(finger)
get :category_index, :category_path => [ 'my-category' ]
- assert_same recent, assigns(:recent_articles)
+ assert_same recent, assigns(:results)[:recent_articles]
end
should 'list recent comments in the category' do
- @controller.expects(:category).returns(@category).at_least_once
recent = []
- finder = CategoryFinder.new(@category)
- finder.expects(:recent).with('comments').returns(recent)
- finder.expects(:recent).with('articles').returns(recent)
- CategoryFinder.expects(:new).with(@category).returns(finder)
+ finger = CategoryFinder.new(@category)
+ finger.expects(:recent).with(anything).at_least_once
+ finger.expects(:recent).with('comments').returns(recent)
+ CategoryFinder.expects(:new).with(@category).returns(finger)
get :category_index, :category_path => [ 'my-category' ]
- assert_same recent, assigns(:recent_comments)
+ assert_same recent, assigns(:results)[:recent_comments]
end
should 'list most commented articles in the category' do
- @controller.expects(:category).returns(@category).at_least_once
most_commented = []
- finder = CategoryFinder.new(@category)
- finder.expects(:most_commented_articles).returns(most_commented)
- CategoryFinder.expects(:new).with(@category).returns(finder)
+ finger = CategoryFinder.new(@category)
+ finger.expects(:most_commented_articles).returns(most_commented)
+ CategoryFinder.expects(:new).with(@category).returns(finger)
get :category_index, :category_path => [ 'my-category' ]
- assert_same most_commented, assigns(:most_commented_articles)
+ assert_same most_commented, assigns(:results)[:most_commented_articles]
end
- should 'display category of products' do
- cat = ProductCategory.create!(:name => 'Food', :environment => Environment.default)
- ent = Enterprise.create!(:name => 'Enterprise test', :identifier => 'enterprise_test')
- p = cat.products.create!(:name => 'product test', :enterprise => ent)
- get :category_index, :category_path => cat.path.split('/')
- assert_includes assigns(:products), p
+ should 'list recently registered people in the category' do
+ recent_people = []
+ finger = CategoryFinder.new(@category)
+ finger.expects(:recent).with(anything).at_least_once
+ finger.expects(:recent).with('people').returns(recent_people)
+ CategoryFinder.expects(:new).with(@category).returns(finger)
+
+ get :category_index, :category_path => [ 'my-category' ]
+ assert_same recent_people, assigns(:results)[:recent_people]
+ end
+
+ should 'list recently registered communities in the category' do
+ recent_communities = []
+ finger = CategoryFinder.new(@category)
+ finger.expects(:recent).with(anything).at_least_once
+ finger.expects(:recent).with('communities').returns(recent_communities)
+ CategoryFinder.expects(:new).with(@category).returns(finger)
+
+ get :category_index, :category_path => [ 'my-category' ]
+ assert_same recent_communities, assigns(:results)[:recent_communities]
+ end
+
+ should 'not list "Search for ..." in category_index' do
+ get :category_index, :category_path => [ 'my-category' ]
+ assert_no_tag :content => /Search for ".*" in the whole site/
end
# SECURITY
--
libgit2 0.21.2