Commit 06f644b6b62816857ace58ce472116f5d68f5b3f
1 parent
99802bbe
Exists in
master
and in
29 other branches
[rails3] Fixed routes
*param is not like 'a/b/c' instead of ['a', 'b', 'c'], so those controllers will need to be changed
Showing
2 changed files
with
34 additions
and
35 deletions
Show diff stats
config/routes.rb
@@ -23,13 +23,13 @@ Noosfero::Application.routes.draw do | @@ -23,13 +23,13 @@ Noosfero::Application.routes.draw do | ||
23 | 23 | ||
24 | match 'site(/:action)', :controller => 'home' | 24 | match 'site(/:action)', :controller => 'home' |
25 | 25 | ||
26 | - match 'images/*stuff' => 'not_found#nothing' | ||
27 | - match 'stylesheets/*stuff' => 'not_found#nothing' | ||
28 | - match 'designs/*stuff' => 'not_found#nothing' | ||
29 | - match 'articles/*stuff' => 'not_found#nothing' | ||
30 | - match 'javascripts/*stuff' => 'not_found#nothing' | ||
31 | - match 'thumbnails/*stuff' => 'not_found#nothing' | ||
32 | - match 'user_themes/*stuff' => 'not_found#nothing' | 26 | + match 'images(/*stuff)' => 'not_found#nothing' |
27 | + match 'stylesheets(/*stuff)' => 'not_found#nothing' | ||
28 | + match 'designs(/*stuff)' => 'not_found#nothing' | ||
29 | + match 'articles(/*stuff)' => 'not_found#nothing' | ||
30 | + match 'javascripts(/*stuff)' => 'not_found#nothing' | ||
31 | + match 'thumbnails(/*stuff)' => 'not_found#nothing' | ||
32 | + match 'user_themes(/*stuff)' => 'not_found#nothing' | ||
33 | 33 | ||
34 | # online documentation | 34 | # online documentation |
35 | match 'doc' => 'doc#index', :as => :doc | 35 | match 'doc' => 'doc#index', :as => :doc |
@@ -41,7 +41,7 @@ Noosfero::Application.routes.draw do | @@ -41,7 +41,7 @@ Noosfero::Application.routes.draw do | ||
41 | match 'account(/:action)', :controller => 'account' | 41 | match 'account(/:action)', :controller => 'account' |
42 | 42 | ||
43 | # enterprise registration | 43 | # enterprise registration |
44 | - match 'enterprise_registration/:action', :controller => 'enterprise_registration' | 44 | + match 'enterprise_registration(/:action)', :controller => 'enterprise_registration' |
45 | 45 | ||
46 | # tags | 46 | # tags |
47 | match 'tag', :controller => 'search', :action => 'tags' | 47 | match 'tag', :controller => 'search', :action => 'tags' |
@@ -51,7 +51,7 @@ Noosfero::Application.routes.draw do | @@ -51,7 +51,7 @@ Noosfero::Application.routes.draw do | ||
51 | match 'cat/*category_path' => 'search#category_index', :as => :category | 51 | match 'cat/*category_path' => 'search#category_index', :as => :category |
52 | match 'assets/:asset(/*category_path)' => 'search#assets', :as => :assets | 52 | match 'assets/:asset(/*category_path)' => 'search#assets', :as => :assets |
53 | # search | 53 | # search |
54 | - match 'search/:action(/*category_path)', :controller => 'search' | 54 | + match 'search(/:action(/*category_path))', :controller => 'search' |
55 | 55 | ||
56 | # events | 56 | # events |
57 | match 'profile/:profile/events_by_day', :controller => 'events', :action => 'events_by_day', :profile => /#{Noosfero.identifier_format}/ | 57 | 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 | @@ -77,33 +77,32 @@ Noosfero::Application.routes.draw do | ||
77 | match 'profile/:profile/search', :controller => 'profile_search', :action => 'index', :profile => /#{Noosfero.identifier_format}/ | 77 | match 'profile/:profile/search', :controller => 'profile_search', :action => 'index', :profile => /#{Noosfero.identifier_format}/ |
78 | 78 | ||
79 | # public profile information | 79 | # public profile information |
80 | - match 'profile/:profile/:action/:id', :controller => 'profile', :action => 'index', :id => /[^\/]*/, :profile => /#{Noosfero.identifier_format}/ | 80 | + match 'profile/:profile(/:action(/:id))', :controller => 'profile', :action => 'index', :id => /[^\/]*/, :profile => /#{Noosfero.identifier_format}/ |
81 | 81 | ||
82 | # contact | 82 | # contact |
83 | - match 'contact/:profile/:action/:id', :controller => 'contact', :action => 'index', :id => /.*/, :profile => /#{Noosfero.identifier_format}/ | 83 | + match 'contact/:profile/:action(/:id)', :controller => 'contact', :action => 'index', :id => /.*/, :profile => /#{Noosfero.identifier_format}/ |
84 | 84 | ||
85 | # map balloon | 85 | # map balloon |
86 | match 'map_balloon/:action/:id', :controller => 'map_balloon', :id => /.*/ | 86 | match 'map_balloon/:action/:id', :controller => 'map_balloon', :id => /.*/ |
87 | 87 | ||
88 | # chat | 88 | # chat |
89 | - match 'chat/:action/:id', :controller => 'chat' | ||
90 | - match 'chat/:action', :controller => 'chat' | 89 | + match 'chat(/:action(/:id))', :controller => 'chat' |
91 | 90 | ||
92 | ###################################################### | 91 | ###################################################### |
93 | ## Controllers that are profile-specific (for profile admins ) | 92 | ## Controllers that are profile-specific (for profile admins ) |
94 | ###################################################### | 93 | ###################################################### |
95 | # profile customization - "My profile" | 94 | # profile customization - "My profile" |
96 | match 'myprofile/:profile', :controller => 'profile_editor', :action => 'index', :profile => /#{Noosfero.identifier_format}/ | 95 | match 'myprofile/:profile', :controller => 'profile_editor', :action => 'index', :profile => /#{Noosfero.identifier_format}/ |
97 | - match 'myprofile/:profile/:controller/:action/:id', :controller => Noosfero.pattern_for_controllers_in_directory('my_profile'), :profile => /#{Noosfero.identifier_format}/ | 96 | + match 'myprofile/:profile/:controller(/:action(/:id))', :controller => Noosfero.pattern_for_controllers_in_directory('my_profile'), :profile => /#{Noosfero.identifier_format}/ |
98 | 97 | ||
99 | 98 | ||
100 | ###################################################### | 99 | ###################################################### |
101 | ## Controllers that are used by environment admin | 100 | ## Controllers that are used by environment admin |
102 | ###################################################### | 101 | ###################################################### |
103 | # administrative tasks for a environment | 102 | # administrative tasks for a environment |
104 | - match 'admin', :controller => 'admin_panel' | ||
105 | - match 'admin/:controller/:action.:format/:id', :controller => Noosfero.pattern_for_controllers_in_directory('admin') | ||
106 | - match 'admin/:controller/:action/:id', :controller => Noosfero.pattern_for_controllers_in_directory('admin') | 103 | + match 'admin', :controller => 'admin_panel', :action => :index |
104 | + match 'admin/:controller(/:action((.:format)/:id))', :controller => Noosfero.pattern_for_controllers_in_directory('admin') | ||
105 | + match 'admin/:controller(/:action(/:id))', :controller => Noosfero.pattern_for_controllers_in_directory('admin') | ||
107 | 106 | ||
108 | 107 | ||
109 | ###################################################### | 108 | ###################################################### |
@@ -111,7 +110,7 @@ Noosfero::Application.routes.draw do | @@ -111,7 +110,7 @@ Noosfero::Application.routes.draw do | ||
111 | ###################################################### | 110 | ###################################################### |
112 | # administrative tasks for a environment | 111 | # administrative tasks for a environment |
113 | match 'system', :controller => 'system' | 112 | match 'system', :controller => 'system' |
114 | - match 'system/:controller/:action/:id', :controller => Noosfero.pattern_for_controllers_in_directory('system') | 113 | + match 'system/:controller(/:action(/:id))', :controller => Noosfero.pattern_for_controllers_in_directory('system') |
115 | 114 | ||
116 | ###################################################### | 115 | ###################################################### |
117 | # plugin routes | 116 | # plugin routes |
test/integration/routing_test.rb
1 | -require "#{File.dirname(__FILE__)}/../test_helper" | 1 | +require File.expand_path('../../test_helper', __FILE__) |
2 | 2 | ||
3 | class RoutingTest < ActionController::IntegrationTest | 3 | class RoutingTest < ActionController::IntegrationTest |
4 | 4 | ||
@@ -74,14 +74,14 @@ class RoutingTest < ActionController::IntegrationTest | @@ -74,14 +74,14 @@ class RoutingTest < ActionController::IntegrationTest | ||
74 | def test_content_viewer | 74 | def test_content_viewer |
75 | 75 | ||
76 | # profile root: | 76 | # profile root: |
77 | - assert_routing('/ze', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze', :page => []) | 77 | + assert_routing('/ze', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze') |
78 | 78 | ||
79 | # some non-root page | 79 | # some non-root page |
80 | - assert_routing('/ze/work/2007', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze', :page => ['work', "2007"]) | 80 | + assert_routing('/ze/work/2007', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze', :page => 'work/2007') |
81 | end | 81 | end |
82 | 82 | ||
83 | def test_category_browser | 83 | def test_category_browser |
84 | - assert_routing('/cat/products/eletronics', :controller => 'search', :action => 'category_index', :category_path => [ 'products', 'eletronics']) | 84 | + assert_routing('/cat/products/eletronics', :controller => 'search', :action => 'category_index', :category_path => 'products/eletronics') |
85 | end | 85 | end |
86 | 86 | ||
87 | #FIXME remove this if design_blocks is not going to be used; or uncomment otherwise; | 87 | #FIXME remove this if design_blocks is not going to be used; or uncomment otherwise; |
@@ -127,19 +127,19 @@ class RoutingTest < ActionController::IntegrationTest | @@ -127,19 +127,19 @@ class RoutingTest < ActionController::IntegrationTest | ||
127 | end | 127 | end |
128 | 128 | ||
129 | def test_search_routing | 129 | def test_search_routing |
130 | - assert_routing('/search', :controller => 'search', :action => 'index', :category_path => []) | 130 | + assert_routing('/search', :controller => 'search', :action => 'index') |
131 | end | 131 | end |
132 | 132 | ||
133 | def test_search_filter_routing | 133 | def test_search_filter_routing |
134 | - assert_routing('/search/filter/a/b', :controller => 'search', :action => 'filter', :category_path => ['a','b']) | 134 | + assert_routing('/search/filter/a/b', :controller => 'search', :action => 'filter', :category_path => 'a/b') |
135 | end | 135 | end |
136 | 136 | ||
137 | def test_assets_routing | 137 | def test_assets_routing |
138 | - assert_routing('/assets/my-asset/a/b/c', :controller => 'search', :action => 'assets', :asset => 'my-asset', :category_path => ['a', 'b', 'c']) | 138 | + assert_routing('/assets/my-asset/a/b/c', :controller => 'search', :action => 'assets', :asset => 'my-asset', :category_path => 'a/b/c') |
139 | end | 139 | end |
140 | 140 | ||
141 | def test_content_view_with_dot | 141 | def test_content_view_with_dot |
142 | - assert_routing('/ze.withdot', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze.withdot', :page => []) | 142 | + assert_routing('/ze.withdot', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze.withdot') |
143 | end | 143 | end |
144 | 144 | ||
145 | def test_content_view_with_dash | 145 | def test_content_view_with_dash |
@@ -147,11 +147,11 @@ class RoutingTest < ActionController::IntegrationTest | @@ -147,11 +147,11 @@ class RoutingTest < ActionController::IntegrationTest | ||
147 | end | 147 | end |
148 | 148 | ||
149 | def test_content_view_with_underscore | 149 | def test_content_view_with_underscore |
150 | - assert_routing('/ze_with_underscore', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze_with_underscore', :page => []) | 150 | + assert_routing('/ze_with_underscore', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze_with_underscore') |
151 | end | 151 | end |
152 | 152 | ||
153 | def test_content_view_with_tilde_routing | 153 | def test_content_view_with_tilde_routing |
154 | - assert_routing('/ze~withtilde', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze~withtilde', :page => []) | 154 | + assert_routing('/ze~withtilde', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze~withtilde') |
155 | end | 155 | end |
156 | 156 | ||
157 | def test_catalog_routing | 157 | def test_catalog_routing |
@@ -229,31 +229,31 @@ class RoutingTest < ActionController::IntegrationTest | @@ -229,31 +229,31 @@ class RoutingTest < ActionController::IntegrationTest | ||
229 | end | 229 | end |
230 | 230 | ||
231 | def test_not_found_images_on_nothing | 231 | def test_not_found_images_on_nothing |
232 | - assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => ['aksdhf']}, '/images/aksdhf') | 232 | + assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => 'aksdhf'}, '/images/aksdhf') |
233 | end | 233 | end |
234 | 234 | ||
235 | def test_not_found_stylesheets_on_nothing | 235 | def test_not_found_stylesheets_on_nothing |
236 | - assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => ['aksdhf']}, '/stylesheets/aksdhf') | 236 | + assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => 'aksdhf'}, '/stylesheets/aksdhf') |
237 | end | 237 | end |
238 | 238 | ||
239 | def test_not_found_designs_on_nothing | 239 | def test_not_found_designs_on_nothing |
240 | - assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => ['aksdhf']}, '/designs/aksdhf') | 240 | + assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => 'aksdhf'}, '/designs/aksdhf') |
241 | end | 241 | end |
242 | 242 | ||
243 | def test_not_found_articles_on_nothing | 243 | def test_not_found_articles_on_nothing |
244 | - assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => ['aksdhf']}, '/articles/aksdhf') | 244 | + assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => 'aksdhf'}, '/articles/aksdhf') |
245 | end | 245 | end |
246 | 246 | ||
247 | def test_not_found_javascripts_on_nothing | 247 | def test_not_found_javascripts_on_nothing |
248 | - assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => ['aksdhf']}, '/javascripts/aksdhf') | 248 | + assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => 'aksdhf'}, '/javascripts/aksdhf') |
249 | end | 249 | end |
250 | 250 | ||
251 | def test_not_found_thumbnails_on_nothing | 251 | def test_not_found_thumbnails_on_nothing |
252 | - assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => ['aksdhf']}, '/thumbnails/aksdhf') | 252 | + assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => 'aksdhf'}, '/thumbnails/aksdhf') |
253 | end | 253 | end |
254 | 254 | ||
255 | def test_not_found_user_themes_on_nothing | 255 | def test_not_found_user_themes_on_nothing |
256 | - assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => ['aksdhf']}, '/user_themes/aksdhf') | 256 | + assert_recognizes({:controller => 'not_found', :action => 'nothing', :stuff => 'aksdhf'}, '/user_themes/aksdhf') |
257 | end | 257 | end |
258 | 258 | ||
259 | end | 259 | end |