Commit f889a85cc55faf96d965f2d29716c6d089197f94
1 parent
d75fce5e
Exists in
master
and in
29 other branches
ActionItem51: code cleanup on category controller
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1584 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
10 additions
and
34 deletions
Show diff stats
app/controllers/public/category_controller.rb
1 | -class CategoryController < ApplicationController | 1 | +class CategoryController < PublicController |
2 | 2 | ||
3 | - before_filter :load_default_enviroment | ||
4 | - | ||
5 | - #FIXME This is not necessary because the application controller define the envrioment | ||
6 | - # as the default holder | ||
7 | - | ||
8 | - def boxes_holder | ||
9 | - environment | ||
10 | - end | ||
11 | - | ||
12 | - def load_default_enviroment | ||
13 | - @environment = Environment.default | 3 | + # view the summary of one category |
4 | + def view | ||
5 | + # TODO: load articles, documents, etc so the view can list them. | ||
14 | end | 6 | end |
15 | 7 | ||
16 | before_filter :load_category, :only => [ :view ] | 8 | before_filter :load_category, :only => [ :view ] |
@@ -22,23 +14,4 @@ class CategoryController < ApplicationController | @@ -22,23 +14,4 @@ class CategoryController < ApplicationController | ||
22 | end | 14 | end |
23 | end | 15 | end |
24 | 16 | ||
25 | - # view the summary of one category | ||
26 | - def view | ||
27 | - send(@category.class.name.underscore.to_sym) | ||
28 | - # TODO: load articles, documents, etc so the view can list them. | ||
29 | - end | ||
30 | - | ||
31 | - protected | ||
32 | - def product_category | ||
33 | - @products = @category.all_products | ||
34 | - @enterprises = Enterprise.find(:all, :conditions => ['products.id in (?)', @products.map(&:id)], :include => :products) | ||
35 | - @users = Profile.find(:all, :conditions => ['consumptions.product_category_id = (?)',@category.id], :include => :consumptions) | ||
36 | - end | ||
37 | - | ||
38 | - def category | ||
39 | - end | ||
40 | - | ||
41 | - def region | ||
42 | - end | ||
43 | - | ||
44 | end | 17 | end |
test/functional/category_controller_test.rb
@@ -11,8 +11,11 @@ class CategoryControllerTest < Test::Unit::TestCase | @@ -11,8 +11,11 @@ class CategoryControllerTest < Test::Unit::TestCase | ||
11 | @response = ActionController::TestResponse.new | 11 | @response = ActionController::TestResponse.new |
12 | end | 12 | end |
13 | 13 | ||
14 | - # Replace this with your real tests. | ||
15 | - def test_truth | ||
16 | - assert true | 14 | + def test_should_display_a_given_category |
15 | + category = Category.create!(:name => 'my category', :environment => Environment.default) | ||
16 | + | ||
17 | + get :view, :path => [ 'my-category' ] | ||
18 | + assert_equal category, assigns(:category) | ||
17 | end | 19 | end |
20 | + | ||
18 | end | 21 | end |