From 06f644b6b62816857ace58ce472116f5d68f5b3f Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Fri, 31 May 2013 22:45:05 -0300 Subject: [PATCH] [rails3] Fixed routes --- config/routes.rb | 35 +++++++++++++++++------------------ test/integration/routing_test.rb | 34 +++++++++++++++++----------------- 2 files changed, 34 insertions(+), 35 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index e1237d4..686713e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -23,13 +23,13 @@ Noosfero::Application.routes.draw do match 'site(/:action)', :controller => 'home' - match 'images/*stuff' => 'not_found#nothing' - match 'stylesheets/*stuff' => 'not_found#nothing' - match 'designs/*stuff' => 'not_found#nothing' - match 'articles/*stuff' => 'not_found#nothing' - match 'javascripts/*stuff' => 'not_found#nothing' - match 'thumbnails/*stuff' => 'not_found#nothing' - match 'user_themes/*stuff' => 'not_found#nothing' + match 'images(/*stuff)' => 'not_found#nothing' + match 'stylesheets(/*stuff)' => 'not_found#nothing' + match 'designs(/*stuff)' => 'not_found#nothing' + match 'articles(/*stuff)' => 'not_found#nothing' + match 'javascripts(/*stuff)' => 'not_found#nothing' + match 'thumbnails(/*stuff)' => 'not_found#nothing' + match 'user_themes(/*stuff)' => 'not_found#nothing' # online documentation match 'doc' => 'doc#index', :as => :doc @@ -41,7 +41,7 @@ Noosfero::Application.routes.draw do match 'account(/:action)', :controller => 'account' # enterprise registration - match 'enterprise_registration/:action', :controller => 'enterprise_registration' + match 'enterprise_registration(/:action)', :controller => 'enterprise_registration' # tags match 'tag', :controller => 'search', :action => 'tags' @@ -51,7 +51,7 @@ Noosfero::Application.routes.draw do match 'cat/*category_path' => 'search#category_index', :as => :category match 'assets/:asset(/*category_path)' => 'search#assets', :as => :assets # search - match 'search/:action(/*category_path)', :controller => 'search' + match 'search(/:action(/*category_path))', :controller => 'search' # events match 'profile/:profile/events_by_day', :controller => 'events', :action => 'events_by_day', :profile => /#{Noosfero.identifier_format}/ @@ -77,33 +77,32 @@ Noosfero::Application.routes.draw do match 'profile/:profile/search', :controller => 'profile_search', :action => 'index', :profile => /#{Noosfero.identifier_format}/ # public profile information - match 'profile/:profile/:action/:id', :controller => 'profile', :action => 'index', :id => /[^\/]*/, :profile => /#{Noosfero.identifier_format}/ + match 'profile/:profile(/:action(/:id))', :controller => 'profile', :action => 'index', :id => /[^\/]*/, :profile => /#{Noosfero.identifier_format}/ # contact - match 'contact/:profile/:action/:id', :controller => 'contact', :action => 'index', :id => /.*/, :profile => /#{Noosfero.identifier_format}/ + match 'contact/:profile/:action(/:id)', :controller => 'contact', :action => 'index', :id => /.*/, :profile => /#{Noosfero.identifier_format}/ # map balloon match 'map_balloon/:action/:id', :controller => 'map_balloon', :id => /.*/ # chat - match 'chat/:action/:id', :controller => 'chat' - match 'chat/:action', :controller => 'chat' + match 'chat(/:action(/:id))', :controller => 'chat' ###################################################### ## Controllers that are profile-specific (for profile admins ) ###################################################### # profile customization - "My profile" match 'myprofile/:profile', :controller => 'profile_editor', :action => 'index', :profile => /#{Noosfero.identifier_format}/ - match 'myprofile/:profile/:controller/:action/:id', :controller => Noosfero.pattern_for_controllers_in_directory('my_profile'), :profile => /#{Noosfero.identifier_format}/ + match 'myprofile/:profile/:controller(/:action(/:id))', :controller => Noosfero.pattern_for_controllers_in_directory('my_profile'), :profile => /#{Noosfero.identifier_format}/ ###################################################### ## Controllers that are used by environment admin ###################################################### # administrative tasks for a environment - match 'admin', :controller => 'admin_panel' - match 'admin/:controller/:action.:format/:id', :controller => Noosfero.pattern_for_controllers_in_directory('admin') - match 'admin/:controller/:action/:id', :controller => Noosfero.pattern_for_controllers_in_directory('admin') + match 'admin', :controller => 'admin_panel', :action => :index + match 'admin/:controller(/:action((.:format)/:id))', :controller => Noosfero.pattern_for_controllers_in_directory('admin') + match 'admin/:controller(/:action(/:id))', :controller => Noosfero.pattern_for_controllers_in_directory('admin') ###################################################### @@ -111,7 +110,7 @@ Noosfero::Application.routes.draw do ###################################################### # administrative tasks for a environment match 'system', :controller => 'system' - match 'system/:controller/:action/:id', :controller => Noosfero.pattern_for_controllers_in_directory('system') + match 'system/:controller(/:action(/:id))', :controller => Noosfero.pattern_for_controllers_in_directory('system') ###################################################### # plugin routes diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index d1911b7..10a3026 100644 --- a/test/integration/routing_test.rb +++ b/test/integration/routing_test.rb @@ -1,4 +1,4 @@ -require "#{File.dirname(__FILE__)}/../test_helper" +require File.expand_path('../../test_helper', __FILE__) class RoutingTest < ActionController::IntegrationTest @@ -74,14 +74,14 @@ class RoutingTest < ActionController::IntegrationTest def test_content_viewer # profile root: - assert_routing('/ze', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze', :page => []) + assert_routing('/ze', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze') # some non-root page - assert_routing('/ze/work/2007', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze', :page => ['work', "2007"]) + assert_routing('/ze/work/2007', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze', :page => 'work/2007') end def test_category_browser - assert_routing('/cat/products/eletronics', :controller => 'search', :action => 'category_index', :category_path => [ 'products', 'eletronics']) + assert_routing('/cat/products/eletronics', :controller => 'search', :action => 'category_index', :category_path => 'products/eletronics') end #FIXME remove this if design_blocks is not going to be used; or uncomment otherwise; @@ -127,19 +127,19 @@ class RoutingTest < ActionController::IntegrationTest end def test_search_routing - assert_routing('/search', :controller => 'search', :action => 'index', :category_path => []) + assert_routing('/search', :controller => 'search', :action => 'index') end def test_search_filter_routing - assert_routing('/search/filter/a/b', :controller => 'search', :action => 'filter', :category_path => ['a','b']) + assert_routing('/search/filter/a/b', :controller => 'search', :action => 'filter', :category_path => 'a/b') end def test_assets_routing - assert_routing('/assets/my-asset/a/b/c', :controller => 'search', :action => 'assets', :asset => 'my-asset', :category_path => ['a', 'b', 'c']) + assert_routing('/assets/my-asset/a/b/c', :controller => 'search', :action => 'assets', :asset => 'my-asset', :category_path => 'a/b/c') end def test_content_view_with_dot - assert_routing('/ze.withdot', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze.withdot', :page => []) + assert_routing('/ze.withdot', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze.withdot') end def test_content_view_with_dash @@ -147,11 +147,11 @@ class RoutingTest < ActionController::IntegrationTest end def test_content_view_with_underscore - assert_routing('/ze_with_underscore', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze_with_underscore', :page => []) + assert_routing('/ze_with_underscore', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze_with_underscore') end def test_content_view_with_tilde_routing - assert_routing('/ze~withtilde', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze~withtilde', :page => []) + assert_routing('/ze~withtilde', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze~withtilde') end def test_catalog_routing @@ -229,31 +229,31 @@ class RoutingTest < ActionController::IntegrationTest end def test_not_found_images_on_nothing - assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => ['aksdhf']}, '/images/aksdhf') + assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => 'aksdhf'}, '/images/aksdhf') end def test_not_found_stylesheets_on_nothing - assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => ['aksdhf']}, '/stylesheets/aksdhf') + assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => 'aksdhf'}, '/stylesheets/aksdhf') end def test_not_found_designs_on_nothing - assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => ['aksdhf']}, '/designs/aksdhf') + assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => 'aksdhf'}, '/designs/aksdhf') end def test_not_found_articles_on_nothing - assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => ['aksdhf']}, '/articles/aksdhf') + assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => 'aksdhf'}, '/articles/aksdhf') end def test_not_found_javascripts_on_nothing - assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => ['aksdhf']}, '/javascripts/aksdhf') + assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => 'aksdhf'}, '/javascripts/aksdhf') end def test_not_found_thumbnails_on_nothing - assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => ['aksdhf']}, '/thumbnails/aksdhf') + assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => 'aksdhf'}, '/thumbnails/aksdhf') end def test_not_found_user_themes_on_nothing - assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => ['aksdhf']}, '/user_themes/aksdhf') + assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => 'aksdhf'}, '/user_themes/aksdhf') end end -- libgit2 0.21.2