diff --git a/app/models/category.rb b/app/models/category.rb index 970dab5..54cd160 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -1,5 +1,6 @@ class Category < ActiveRecord::Base + validates_exclusion_of :slug, :in => [ 'index'], :message => N_('%{fm} cannot be like that.') validates_presence_of :name, :environment_id validates_uniqueness_of :slug,:scope => [ :environment_id, :parent_id ], :message => N_('%{fn} is already being used by another category.') belongs_to :environment diff --git a/config/routes.rb b/config/routes.rb index be69940..3bb7551 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -53,8 +53,9 @@ ActionController::Routing::Routes.draw do |map| ###################################################### ## Public controllers ###################################################### - - map.connect 'cat/:action/*path', :controller => 'category', :action => 'index' + + map.connect 'cat', :controller => 'category', :action => 'index' + map.category 'cat/*path', :controller => 'category', :action => 'view' # *content viewing* # XXX this route must come last so other routes have priority over it. diff --git a/test/functional/category_controller_test.rb b/test/functional/category_controller_test.rb new file mode 100644 index 0000000..edf9106 --- /dev/null +++ b/test/functional/category_controller_test.rb @@ -0,0 +1,18 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'category_controller' + +# Re-raise errors caught by the controller. +class CategoryController; def rescue_action(e) raise e end; end + +class CategoryControllerTest < Test::Unit::TestCase + def setup + @controller = CategoryController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + end + + # Replace this with your real tests. + def test_truth + assert true + end +end diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index 772f519..d5c7d4e 100644 --- a/test/integration/routing_test.rb +++ b/test/integration/routing_test.rb @@ -71,8 +71,8 @@ class RoutingTest < ActionController::IntegrationTest end def test_category_browser - assert_routing('/cat/some_action/products/eletronics', :controller => 'category', :action => 'some_action', :path => [ 'products', 'eletronics']) - assert_routing('/cat', :controller => 'category', :action => 'index', :path => [ ]) + assert_routing('/cat/products/eletronics', :controller => 'category', :action => 'view', :path => [ 'products', 'eletronics']) + assert_routing('/cat', :controller => 'category', :action => 'index') end end -- libgit2 0.21.2