From f889a85cc55faf96d965f2d29716c6d089197f94 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Thu, 13 Mar 2008 21:46:20 +0000 Subject: [PATCH] ActionItem51: code cleanup on category controller --- app/controllers/public/category_controller.rb | 35 ++++------------------------------- test/functional/category_controller_test.rb | 9 ++++++--- 2 files changed, 10 insertions(+), 34 deletions(-) diff --git a/app/controllers/public/category_controller.rb b/app/controllers/public/category_controller.rb index e7f23cc..e2d8a92 100644 --- a/app/controllers/public/category_controller.rb +++ b/app/controllers/public/category_controller.rb @@ -1,16 +1,8 @@ -class CategoryController < ApplicationController +class CategoryController < PublicController - before_filter :load_default_enviroment - - #FIXME This is not necessary because the application controller define the envrioment - # as the default holder - - def boxes_holder - environment - end - - def load_default_enviroment - @environment = Environment.default + # view the summary of one category + def view + # TODO: load articles, documents, etc so the view can list them. end before_filter :load_category, :only => [ :view ] @@ -22,23 +14,4 @@ class CategoryController < ApplicationController end end - # view the summary of one category - def view - send(@category.class.name.underscore.to_sym) - # TODO: load articles, documents, etc so the view can list them. - end - - protected - def product_category - @products = @category.all_products - @enterprises = Enterprise.find(:all, :conditions => ['products.id in (?)', @products.map(&:id)], :include => :products) - @users = Profile.find(:all, :conditions => ['consumptions.product_category_id = (?)',@category.id], :include => :consumptions) - end - - def category - end - - def region - end - end diff --git a/test/functional/category_controller_test.rb b/test/functional/category_controller_test.rb index edf9106..784bd2d 100644 --- a/test/functional/category_controller_test.rb +++ b/test/functional/category_controller_test.rb @@ -11,8 +11,11 @@ class CategoryControllerTest < Test::Unit::TestCase @response = ActionController::TestResponse.new end - # Replace this with your real tests. - def test_truth - assert true + def test_should_display_a_given_category + category = Category.create!(:name => 'my category', :environment => Environment.default) + + get :view, :path => [ 'my-category' ] + assert_equal category, assigns(:category) end + end -- libgit2 0.21.2