Commit ed55018e925d7b8746aeba7fd14860671bf8c088
1 parent
c230d671
Exists in
master
and in
22 other branches
ActionItem70: changed routing to category_controller
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@532 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
4 changed files
with
24 additions
and
4 deletions
Show diff stats
app/models/category.rb
1 | class Category < ActiveRecord::Base | 1 | class Category < ActiveRecord::Base |
2 | 2 | ||
3 | + validates_exclusion_of :slug, :in => [ 'index'], :message => N_('%{fm} cannot be like that.') | ||
3 | validates_presence_of :name, :environment_id | 4 | validates_presence_of :name, :environment_id |
4 | validates_uniqueness_of :slug,:scope => [ :environment_id, :parent_id ], :message => N_('%{fn} is already being used by another category.') | 5 | validates_uniqueness_of :slug,:scope => [ :environment_id, :parent_id ], :message => N_('%{fn} is already being used by another category.') |
5 | belongs_to :environment | 6 | belongs_to :environment |
config/routes.rb
@@ -53,8 +53,9 @@ ActionController::Routing::Routes.draw do |map| | @@ -53,8 +53,9 @@ ActionController::Routing::Routes.draw do |map| | ||
53 | ###################################################### | 53 | ###################################################### |
54 | ## Public controllers | 54 | ## Public controllers |
55 | ###################################################### | 55 | ###################################################### |
56 | - | ||
57 | - map.connect 'cat/:action/*path', :controller => 'category', :action => 'index' | 56 | + |
57 | + map.connect 'cat', :controller => 'category', :action => 'index' | ||
58 | + map.category 'cat/*path', :controller => 'category', :action => 'view' | ||
58 | 59 | ||
59 | # *content viewing* | 60 | # *content viewing* |
60 | # XXX this route must come last so other routes have priority over it. | 61 | # XXX this route must come last so other routes have priority over it. |
@@ -0,0 +1,18 @@ | @@ -0,0 +1,18 @@ | ||
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 | + end | ||
13 | + | ||
14 | + # Replace this with your real tests. | ||
15 | + def test_truth | ||
16 | + assert true | ||
17 | + end | ||
18 | +end |
test/integration/routing_test.rb
@@ -71,8 +71,8 @@ class RoutingTest < ActionController::IntegrationTest | @@ -71,8 +71,8 @@ class RoutingTest < ActionController::IntegrationTest | ||
71 | end | 71 | end |
72 | 72 | ||
73 | def test_category_browser | 73 | def test_category_browser |
74 | - assert_routing('/cat/some_action/products/eletronics', :controller => 'category', :action => 'some_action', :path => [ 'products', 'eletronics']) | ||
75 | - assert_routing('/cat', :controller => 'category', :action => 'index', :path => [ ]) | 74 | + assert_routing('/cat/products/eletronics', :controller => 'category', :action => 'view', :path => [ 'products', 'eletronics']) |
75 | + assert_routing('/cat', :controller => 'category', :action => 'index') | ||
76 | end | 76 | end |
77 | 77 | ||
78 | end | 78 | end |