Commit 4ae1f84f642f4c0309cdb144c28deadc95abe3c2

Authored by AntonioTerceiro
1 parent 1d955bbb

ActionItem155: refactoring: moving functionality from category_controller to sea…

…rch_controller, and removing the former.


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1624 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/public/category_controller.rb
... ... @@ -1,27 +0,0 @@
1   -class CategoryController < PublicController
2   -
3   - # view the summary of one category
4   - def view
5   - send('action_' + @category.class.name.underscore)
6   - end
7   -
8   - attr_reader :category
9   -
10   - before_filter :load_category, :only => [ :view ]
11   - private
12   -
13   - def action_product_category
14   - @products = category.products
15   - @enterprises = category.products.map{|p| p.enterprise}.flatten.uniq
16   - @users = category.consumers
17   - end
18   -
19   - def action_category
20   - # TODO: load articles, documents, etc so the view can list them.
21   - @recent_articles = category.recent_articles
22   - @recent_comments = category.recent_comments
23   - @most_commented_articles = category.most_commented_articles
24   - end
25   - alias :action_region :action_category
26   -
27   -end
app/controllers/public/search_controller.rb
... ... @@ -24,6 +24,19 @@ class SearchController &lt; ApplicationController
24 24 end
25 25 end
26 26  
  27 + def action_product_category
  28 + @products = category.products
  29 + @enterprises = category.products.map{|p| p.enterprise}.flatten.uniq
  30 + @users = category.consumers
  31 + end
  32 +
  33 + def action_category
  34 + @recent_articles = category.recent_articles
  35 + @recent_comments = category.recent_comments
  36 + @most_commented_articles = category.most_commented_articles
  37 + end
  38 + alias :action_region :action_category
  39 +
27 40 public
28 41  
29 42 include SearchHelper
... ... @@ -53,6 +66,12 @@ class SearchController &lt; ApplicationController
53 66  
54 67 #######################################################
55 68  
  69 + # view the summary of one category
  70 + def category_index
  71 + send('action_' + @category.class.name.underscore)
  72 + end
  73 + attr_reader :category
  74 +
56 75 def tags
57 76 @tags = Tag.find(:all).inject({}) do |memo,tag|
58 77 memo[tag.name] = tag.taggings.count
... ...
app/helpers/application_helper.rb
... ... @@ -309,7 +309,7 @@ module ApplicationHelper
309 309 def link_to_category(category, full = true)
310 310 return _('Uncategorized product') unless category
311 311 name = full ? category.full_name : category.name
312   - link_to name, :controller => 'category', :action => 'view', :category_path => category.path.split('/')
  312 + link_to name, :controller => 'search', :action => 'category_index', :category_path => category.path.split('/')
313 313 end
314 314  
315 315 def link_to_product(product)
... ...
app/views/category/_article.rhtml
... ... @@ -1,9 +0,0 @@
1   -<li>
2   - <strong><%= link_to(article.title, article.url) %></strong>
3   - <div class="item_meta">
4   - <span class="cat_item_by"><%=
5   - _('by %s') % link_to(article.last_changed_by.name, article.last_changed_by.url)
6   - %></span>
7   - <span class="cat_item_update"><%= _('Last update: %s.') % show_date(article.updated_on) %></span>
8   - </div>
9   -</li>
app/views/category/_category.rhtml
... ... @@ -1,24 +0,0 @@
1   -<h2><%= _('Recent articles') %></h2>
2   -<ul class="recent_on_cat recent_articles">
3   - <%= render :partial => 'article', :collection => @recent_articles %>
4   -</ul>
5   -
6   -<h2><%= _('Recent Comments') %></h2>
7   -<ul class="recent_on_cat recent_comments">
8   -<% @recent_comments.each do |comment| %>
9   - <li>
10   - <strong><%= link_to(comment.title, comment.url) %></strong>
11   - <div class="item_meta">
12   - <%= _('by %{author} on "%{article}"') % {
13   - :comment => link_to(comment.title, comment.url),
14   - :article => link_to(comment.article.title, comment.article.url),
15   - :author => comment.author_name } %>
16   - </div>
17   - </li>
18   -<% end %>
19   -</ul>
20   -
21   -<h2><%= _('Most commented articles') %></h2>
22   -<ul class="most_commented">
23   - <%= render :partial => 'article', :collection => @most_commented_articles %>
24   -</ul>
app/views/category/_product_category.rhtml
... ... @@ -1,29 +0,0 @@
1   -<%= 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? %>
2   -<ul>
3   - <li><%= n_("One product in this category.", "%{num} products in this category.", @products.size) % { :num => @products.size } %></li>
4   - <li><%= n_("One enterprise sells products in this category.", "%{num} enterprises sells products in this category.", @enterprises.size) % { :num => @enterprises.size} %></li>
5   - <li><%= n_("One user consumes this product.", "%{num} users consumes this product", @users.size) % {:num => @users.size} %></li>
6   -</ul>
7   -
8   -<h3> <%= _('Products under this category:') %> </h3>
9   -<ul>
10   - <% @products.each do |p| %>
11   - <li>
12   - <%= image_tag p.image.public_filename(:thumb) if p.image%>
13   - <%= link_to_product(p) %> <br/>
14   - <% if p.price %>
15   - <%= _('Price: %d') % p.price %> <br/>
16   - <% end %>
17   - <%= _('Enterprise:') %> <%= link_to_homepage p.enterprise.name, p.enterprise.identifier %> <br/><br/>
18   - </li>
19   - <% end %>
20   -</ul>
21   -
22   -<h3><%= _('Users that consumes products in this category:') %></h3>
23   -
24   -<% @users.each do |u| %>
25   - <p>
26   - <%= image_tag u.image.public_filename(:thumb) if u.image %> <br>
27   - <%= link_to_homepage(u.name, u.identifier) %>
28   - </p>
29   -<% end %>
app/views/category/_region.rhtml
... ... @@ -1 +0,0 @@
1   -_category.rhtml
2 0 \ No newline at end of file
app/views/category/view.rhtml
... ... @@ -1,29 +0,0 @@
1   -<div id="view-category">
2   -
3   - <div id="category-ancestors">
4   - <%= @category.ancestors.reverse.map { |a| link_to_category(a, false) }.join(' &rarr; ') %>
5   - </div><!-- end id="category-ancestors" -->
6   -
7   - <h1 id="categiry-name"><%= _('Category: %s') % @category.name %></h1>
8   -
9   - <div class="category_itens">
10   - <%= render :partial => @category.class.name.underscore %>
11   - </div><!-- end class="category_itens" -->
12   -
13   - <div id="category-childs">
14   - <h2> <%= _('Sub-categories') %> </h2>
15   -
16   - <% if @category.children.empty? %>
17   - <strong id="cat-no-child"><%= _('No sub-categories') %></strong>
18   - <% else %>
19   - <ul>
20   - <% @category.children.each do |c| %>
21   - <li> <%= link_to_category(c) %> </li>
22   - <% end %>
23   - </ul>
24   - <% end %>
25   -
26   - </div><!-- end id="child-categories" -->
27   -
28   -</div><!-- end id="view-category" -->
29   -
app/views/search/_article.rhtml
1   - <div class='search-result-text'>
2   - <div>
3   - <strong>
4   - <%= link_to_document(hit) %>
5   - </strong>
6   - </div>
7   - <div>
8   - <%= strip_tags(hit.abstract) %>
9   - </div>
  1 +<li>
  2 + <strong><%= link_to(hit.title, hit.url) %></strong>
  3 + <div class="item_meta">
  4 + <% if hit.last_changed_by %>
  5 + <span class="cat_item_by">
  6 + <%= _('by %s') % link_to(hit.last_changed_by.name, hit.last_changed_by.url) %>
  7 + </span>
  8 + <% end %>
  9 + <span class="cat_item_update"><%= _('Last update: %s.') % show_date(hit.updated_on) %></span>
10 10 </div>
  11 +</li>
... ...
app/views/search/_category.rhtml 0 → 100644
... ... @@ -0,0 +1,24 @@
  1 +<h2><%= _('Recent articles') %></h2>
  2 +<ul class="recent_on_cat recent_articles">
  3 + <%= render :partial => 'article', :collection => @recent_articles %>
  4 +</ul>
  5 +
  6 +<h2><%= _('Recent Comments') %></h2>
  7 +<ul class="recent_on_cat recent_comments">
  8 +<% @recent_comments.each do |comment| %>
  9 + <li>
  10 + <strong><%= link_to(comment.title, comment.url) %></strong>
  11 + <div class="item_meta">
  12 + <%= _('by %{author} on "%{article}"') % {
  13 + :comment => link_to(comment.title, comment.url),
  14 + :article => link_to(comment.article.title, comment.article.url),
  15 + :author => comment.author_name } %>
  16 + </div>
  17 + </li>
  18 +<% end %>
  19 +</ul>
  20 +
  21 +<h2><%= _('Most commented articles') %></h2>
  22 +<ul class="most_commented">
  23 + <%= render :partial => 'article', :collection => @most_commented_articles %>
  24 +</ul>
... ...
app/views/search/_comment.rhtml
1   - <div class='search-result-text'>
2   - <div>
3   - <strong>
4   - <%= link_to(hit.title, hit.url) %>
5   - </strong>
6   - </div>
7   - <div>
8   - <%= strip_tags(hit.body) %>
9   - </div>
  1 +<li>
  2 + <strong><%= link_to(hit.title, hit.url)%></strong>
  3 + <div class="item_meta">
  4 + <span class="cat_item_by"><%= _('by %s, on "%s"') % [hit.author_name, link_to(hit.article.name, hit.article.url)] %></span>
10 5 </div>
  6 +</li>
  7 +
  8 +
... ...
app/views/search/_product.rhtml
1 1 <%# FIXME add more information %>
2 2  
  3 +<li>
3 4 <div class='search-result-text'>
4 5 <%= image_tag(hit.image.public_filename(:minor)) if hit.image %>
5 6 <strong>
... ... @@ -13,3 +14,4 @@
13 14 <li> <%= _('Category: %s') % link_to_category(hit.product_category) %> </li>
14 15 </ul>
15 16 </div>
  17 +</li>
... ...
app/views/search/_product_category.rhtml 0 → 100644
... ... @@ -0,0 +1,29 @@
  1 +<%= 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? %>
  2 +<ul>
  3 + <li><%= n_("One product in this category.", "%{num} products in this category.", @products.size) % { :num => @products.size } %></li>
  4 + <li><%= n_("One enterprise sells products in this category.", "%{num} enterprises sells products in this category.", @enterprises.size) % { :num => @enterprises.size} %></li>
  5 + <li><%= n_("One user consumes this product.", "%{num} users consumes this product", @users.size) % {:num => @users.size} %></li>
  6 +</ul>
  7 +
  8 +<h3> <%= _('Products under this category:') %> </h3>
  9 +<ul>
  10 + <% @products.each do |p| %>
  11 + <li>
  12 + <%= image_tag p.image.public_filename(:thumb) if p.image%>
  13 + <%= link_to_product(p) %> <br/>
  14 + <% if p.price %>
  15 + <%= _('Price: %d') % p.price %> <br/>
  16 + <% end %>
  17 + <%= _('Enterprise:') %> <%= link_to_homepage p.enterprise.name, p.enterprise.identifier %> <br/><br/>
  18 + </li>
  19 + <% end %>
  20 +</ul>
  21 +
  22 +<h3><%= _('Users that consumes products in this category:') %></h3>
  23 +
  24 +<% @users.each do |u| %>
  25 + <p>
  26 + <%= image_tag u.image.public_filename(:thumb) if u.image %> <br>
  27 + <%= link_to_homepage(u.name, u.identifier) %>
  28 + </p>
  29 +<% end %>
... ...
app/views/search/_profile.rhtml
1 1 <%# FIXME add more information %>
2   -
3   -<div class='search-result-text'>
4   - <%= image_tag(hit.image.public_filename(:minor)) if hit.image %>
5   - <strong>
6   - <%= link_to_homepage(hit.name, hit.identifier) %>
7   - </strong>
8   -</div>
  2 +<li>
  3 + <div class='search-result-text'>
  4 + <%= image_tag(hit.image.public_filename(:minor)) if hit.image %>
  5 + <strong>
  6 + <%= link_to_homepage(hit.name, hit.identifier) %>
  7 + </strong>
  8 + </div>
  9 +</li>
... ...
app/views/search/_region.rhtml 0 → 120000
... ... @@ -0,0 +1 @@
  1 +_category.rhtml
0 2 \ No newline at end of file
... ...
app/views/search/category_index.rhtml 0 → 100644
... ... @@ -0,0 +1,29 @@
  1 +<div id="view-category">
  2 +
  3 + <div id="category-ancestors">
  4 + <%= @category.ancestors.reverse.map { |a| link_to_category(a, false) }.join(' &rarr; ') %>
  5 + </div><!-- end id="category-ancestors" -->
  6 +
  7 + <h1 id="categiry-name"><%= _('Category: %s') % @category.name %></h1>
  8 +
  9 + <div class="category_itens">
  10 + <%= render :partial => @category.class.name.underscore %>
  11 + </div><!-- end class="category_itens" -->
  12 +
  13 + <div id="category-childs">
  14 + <h2> <%= _('Sub-categories') %> </h2>
  15 +
  16 + <% if @category.children.empty? %>
  17 + <strong id="cat-no-child"><%= _('No sub-categories') %></strong>
  18 + <% else %>
  19 + <ul>
  20 + <% @category.children.each do |c| %>
  21 + <li> <%= link_to_category(c) %> </li>
  22 + <% end %>
  23 + </ul>
  24 + <% end %>
  25 +
  26 + </div><!-- end id="child-categories" -->
  27 +
  28 +</div><!-- end id="view-category" -->
  29 +
... ...
app/views/search/index.rhtml
... ... @@ -4,9 +4,11 @@
4 4 <% if !results.nil? and !results.empty? %>
5 5 <div id="search-results-<%= name %>">
6 6 <h3><%= @names[name] %></h3>
  7 + <ul>
7 8 <% results.each do |hit| %>
8 9 <%= render :partial => partial_for_class(hit.class), :locals => { :hit => hit } %>
9 10 <% end %>
  11 + </ul>
10 12 </div>
11 13 <% end %>
12 14 <% end %>
... ...
app/views/shared/categories_menu.rhtml
... ... @@ -5,7 +5,7 @@
5 5 <%= item.name %>
6 6 <ul>
7 7 <% item.children.each do |child| %>
8   - <li><%= link_to(content_tag('span', child.name), :controller => 'category', :action => 'view', :category_path => child.explode_path) %></li>
  8 + <li><%= link_to(content_tag('span', child.name), :controller => 'search', :action => 'category_index', :category_path => child.explode_path) %></li>
9 9 <% end %>
10 10 </ul>
11 11 </li>
... ...
config/routes.rb
... ... @@ -29,13 +29,12 @@ ActionController::Routing::Routes.draw do |map|
29 29 # tags
30 30 map.tag 'tag', :controller => 'search', :action => 'tags'
31 31 map.tag 'tag/:tag', :controller => 'search', :action => 'tag'
32   -
  32 + # categories index
  33 + map.category 'cat/*category_path', :controller => 'search', :action => 'category_index'
  34 + map.assets 'assets/:asset/*category_path', :controller => 'search', :action => 'assets'
33 35 # search
34 36 map.connect 'search/:action/*category_path', :controller => 'search'
35 37  
36   - # categories controller
37   - map.connect 'cat', :controller => 'category', :action => 'index'
38   - map.category 'cat/*category_path', :controller => 'category', :action => 'view'
39 38  
40 39 # public profile information
41 40 map.profile 'profile/:profile/:action/:id', :controller => 'profile', :action => 'index'
... ...
test/functional/category_controller_test.rb
... ... @@ -1,61 +0,0 @@
1   -require File.dirname(__FILE__) + '/../test_helper'
2   -require 'category_controller'
3   -
4   -# Re-raise errors caught by the controller.
5   -class CategoryController; def rescue_action(e) raise e end; end
6   -
7   -class CategoryControllerTest < Test::Unit::TestCase
8   - def setup
9   - @controller = CategoryController.new
10   - @request = ActionController::TestRequest.new
11   - @response = ActionController::TestResponse.new
12   -
13   - @category = Category.create!(:name => 'my category', :environment => Environment.default)
14   - end
15   -
16   - def test_should_display_a_given_category
17   - get :view, :category_path => [ 'my-category' ]
18   - assert_equal @category, assigns(:category)
19   - end
20   -
21   - should 'expose category in a method' do
22   - get :view, :category_path => [ 'my-category' ]
23   - assert_same assigns(:category), @controller.category
24   - end
25   -
26   - should 'list recent articles in the category' do
27   - @controller.expects(:category).returns(@category).at_least_once
28   - recent = []
29   - @category.expects(:recent_articles).returns(recent)
30   -
31   - get :view, :category_path => [ 'my-category' ]
32   - assert_same recent, assigns(:recent_articles)
33   - end
34   -
35   - should 'list recent comments in the category' do
36   - @controller.expects(:category).returns(@category).at_least_once
37   - recent = []
38   - @category.expects(:recent_comments).returns(recent)
39   -
40   - get :view, :category_path => [ 'my-category' ]
41   - assert_same recent, assigns(:recent_comments)
42   - end
43   -
44   - should 'list most commented articles in the category' do
45   - @controller.expects(:category).returns(@category).at_least_once
46   - most_commented = []
47   - @category.expects(:most_commented_articles).returns(most_commented)
48   -
49   - get :view, :category_path => [ 'my-category' ]
50   - assert_same most_commented, assigns(:most_commented_articles)
51   - end
52   -
53   - should 'display category of products' do
54   - cat = ProductCategory.create!(:name => 'Food', :environment => Environment.default)
55   - ent = Enterprise.create!(:name => 'Enterprise test', :identifier => 'enterprise_test')
56   - p = cat.products.create!(:name => 'product test', :enterprise => ent)
57   - get :view, :category_path => cat.path.split('/')
58   - assert_includes assigns(:products), p
59   - end
60   -
61   -end
test/functional/search_controller_test.rb
... ... @@ -9,6 +9,8 @@ class SearchControllerTest &lt; Test::Unit::TestCase
9 9 @controller = SearchController.new
10 10 @request = ActionController::TestRequest.new
11 11 @response = ActionController::TestResponse.new
  12 +
  13 + @category = Category.create!(:name => 'my category', :environment => Environment.default)
12 14 end
13 15  
14 16 should 'filter stop words' do
... ... @@ -52,11 +54,10 @@ class SearchControllerTest &lt; Test::Unit::TestCase
52 54  
53 55 should 'search for articles in a specific category' do
54 56 person = create_user('teste').person
55   - category = Category.create!(:name => 'my category', :environment => Environment.default)
56 57  
57 58 # in category
58 59 art1 = person.articles.build(:name => 'an article to be found')
59   - art1.categories << category
  60 + art1.categories << @category
60 61 art1.save!
61 62  
62 63 # not in category
... ... @@ -83,11 +84,10 @@ class SearchControllerTest &lt; Test::Unit::TestCase
83 84  
84 85 should 'search in comments in a specific category' do
85 86 person = create_user('teste').person
86   - category = Category.create!(:name => 'my category', :environment => Environment.default)
87 87  
88 88 # in category
89 89 art1 = person.articles.build(:name => 'an article to be found')
90   - art1.categories << category
  90 + art1.categories << @category
91 91 art1.save!
92 92 comment1 = art1.comments.build(:title => 'comment to be found', :body => 'hfyfyh', :author => person); comment1.save!
93 93  
... ... @@ -108,10 +108,9 @@ class SearchControllerTest &lt; Test::Unit::TestCase
108 108 end
109 109  
110 110 should 'find enterprises in a specified category' do
111   - category = Category.create!(:name => 'my category', :environment => Environment.default)
112 111  
113 112 # in category
114   - ent1 = Enterprise.create!(:name => 'testing enterprise 1', :identifier => 'test1', :categories => [category])
  113 + ent1 = Enterprise.create!(:name => 'testing enterprise 1', :identifier => 'test1', :categories => [@category])
115 114  
116 115 # not in category
117 116 ent2 = Enterprise.create!(:name => 'testing enterprise 2', :identifier => 'test2')
... ... @@ -132,8 +131,7 @@ class SearchControllerTest &lt; Test::Unit::TestCase
132 131 end
133 132  
134 133 should 'find people in a specific category' do
135   - c = Category.create!(:name => 'my category', :environment => Environment.default)
136   - p1 = create_user('people_1').person; p1.name = 'a beautiful person'; p1.categories << c; p1.save!
  134 + p1 = create_user('people_1').person; p1.name = 'a beautiful person'; p1.categories << @category; p1.save!
137 135 p2 = create_user('people_2').person; p2.name = 'another beautiful person'; p2.save!
138 136 get :index, :category_path => [ 'my-category' ], :query => 'beautiful', :find_in => [ 'people' ]
139 137 assert_includes assigns(:results)[:people], p1
... ... @@ -150,10 +148,9 @@ class SearchControllerTest &lt; Test::Unit::TestCase
150 148 end
151 149  
152 150 should 'find communities in a specified category' do
153   - c = Category.create!(:name => 'my category', :environment => Environment.default)
154 151 c1 = Community.create!(:name => 'a beautiful community', :identifier => 'bea_comm', :environment => Environment.default)
155 152 c2 = Community.create!(:name => 'another beautiful community', :identifier => 'an_bea_comm', :environment => Environment.default)
156   - c1.categories << c; c1.save!
  153 + c1.categories << @category; c1.save!
157 154 get :index, :category_path => [ 'my-category' ], :query => 'beautiful', :find_in => [ 'communities' ]
158 155 assert_includes assigns(:results)[:communities], c1
159 156 assert_not_includes assigns(:results)[:communities], c2
... ... @@ -169,8 +166,7 @@ class SearchControllerTest &lt; Test::Unit::TestCase
169 166 end
170 167  
171 168 should 'find products in a specific category' do
172   - c = Category.create!(:name => 'my category', :environment => Environment.default)
173   - ent1 = Enterprise.create!(:name => 'teste1', :identifier => 'teste1'); ent1.categories << c
  169 + ent1 = Enterprise.create!(:name => 'teste1', :identifier => 'teste1'); ent1.categories << @category
174 170 ent2 = Enterprise.create!(:name => 'teste2', :identifier => 'teste2')
175 171 prod1 = ent1.products.create!(:name => 'a beautiful product')
176 172 prod2 = ent2.products.create!(:name => 'another beautiful product')
... ... @@ -261,4 +257,49 @@ class SearchControllerTest &lt; Test::Unit::TestCase
261 257 assert_tag :tag => 'form' , :attributes => { :method => 'get' }
262 258 end
263 259  
  260 + def test_should_display_a_given_category
  261 + get :category_index, :category_path => [ 'my-category' ]
  262 + assert_equal @category, assigns(:category)
  263 + end
  264 +
  265 + should 'expose category in a method' do
  266 + get :category_index, :category_path => [ 'my-category' ]
  267 + assert_same assigns(:category), @controller.category
  268 + end
  269 +
  270 + should 'list recent articles in the category' do
  271 + @controller.expects(:category).returns(@category).at_least_once
  272 + recent = []
  273 + @category.expects(:recent_articles).returns(recent)
  274 +
  275 + get :category_index, :category_path => [ 'my-category' ]
  276 + assert_same recent, assigns(:recent_articles)
  277 + end
  278 +
  279 + should 'list recent comments in the category' do
  280 + @controller.expects(:category).returns(@category).at_least_once
  281 + recent = []
  282 + @category.expects(:recent_comments).returns(recent)
  283 +
  284 + get :category_index, :category_path => [ 'my-category' ]
  285 + assert_same recent, assigns(:recent_comments)
  286 + end
  287 +
  288 + should 'list most commented articles in the category' do
  289 + @controller.expects(:category).returns(@category).at_least_once
  290 + most_commented = []
  291 + @category.expects(:most_commented_articles).returns(most_commented)
  292 +
  293 + get :category_index, :category_path => [ 'my-category' ]
  294 + assert_same most_commented, assigns(:most_commented_articles)
  295 + end
  296 +
  297 + should 'display category of products' do
  298 + cat = ProductCategory.create!(:name => 'Food', :environment => Environment.default)
  299 + ent = Enterprise.create!(:name => 'Enterprise test', :identifier => 'enterprise_test')
  300 + p = cat.products.create!(:name => 'product test', :enterprise => ent)
  301 + get :category_index, :category_path => cat.path.split('/')
  302 + assert_includes assigns(:products), p
  303 + end
  304 +
264 305 end
... ...
test/integration/routing_test.rb
... ... @@ -69,8 +69,7 @@ class RoutingTest &lt; ActionController::IntegrationTest
69 69 end
70 70  
71 71 def test_category_browser
72   - assert_routing('/cat/products/eletronics', :controller => 'category', :action => 'view', :category_path => [ 'products', 'eletronics'])
73   - assert_routing('/cat', :controller => 'category', :action => 'index')
  72 + assert_routing('/cat/products/eletronics', :controller => 'search', :action => 'category_index', :category_path => [ 'products', 'eletronics'])
74 73 end
75 74  
76 75 #FIXME remove this if design_blocks is not going to be used; or uncomment otherwise;
... ... @@ -99,4 +98,8 @@ class RoutingTest &lt; ActionController::IntegrationTest
99 98 assert_routing('/search/filter/a/b', :controller => 'search', :action => 'filter', :category_path => ['a','b'])
100 99 end
101 100  
  101 + def test_assets_routing
  102 + assert_routing('/assets/my-asset/a/b/c', :controller => 'search', :action => 'assets', :asset => 'my-asset', :category_path => ['a', 'b', 'c'])
  103 + end
  104 +
102 105 end
... ...
test/unit/application_helper_test.rb
... ... @@ -67,7 +67,7 @@ class ApplicationHelperTest &lt; Test::Unit::TestCase
67 67 cat.expects(:full_name).returns('category name')
68 68  
69 69 result = "/cat/my-category/my-subcatagory"
70   - expects(:link_to).with('category name', :controller => 'category', :action => 'view', :category_path => ['my-category', 'my-subcatagory']).returns(result)
  70 + expects(:link_to).with('category name', :controller => 'search', :action => 'category_index', :category_path => ['my-category', 'my-subcatagory']).returns(result)
71 71 assert_same result, link_to_category(cat)
72 72 end
73 73  
... ...