Commit 06f644b6b62816857ace58ce472116f5d68f5b3f

Authored by Antonio Terceiro
1 parent 99802bbe

[rails3] Fixed routes

*param is not like 'a/b/c' instead of ['a', 'b', 'c'], so those
controllers will need to be changed
config/routes.rb
... ... @@ -23,13 +23,13 @@ Noosfero::Application.routes.draw do
23 23  
24 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 34 # online documentation
35 35 match 'doc' => 'doc#index', :as => :doc
... ... @@ -41,7 +41,7 @@ Noosfero::Application.routes.draw do
41 41 match 'account(/:action)', :controller => 'account'
42 42  
43 43 # enterprise registration
44   - match 'enterprise_registration/:action', :controller => 'enterprise_registration'
  44 + match 'enterprise_registration(/:action)', :controller => 'enterprise_registration'
45 45  
46 46 # tags
47 47 match 'tag', :controller => 'search', :action => 'tags'
... ... @@ -51,7 +51,7 @@ Noosfero::Application.routes.draw do
51 51 match 'cat/*category_path' => 'search#category_index', :as => :category
52 52 match 'assets/:asset(/*category_path)' => 'search#assets', :as => :assets
53 53 # search
54   - match 'search/:action(/*category_path)', :controller => 'search'
  54 + match 'search(/:action(/*category_path))', :controller => 'search'
55 55  
56 56 # events
57 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 77 match 'profile/:profile/search', :controller => 'profile_search', :action => 'index', :profile => /#{Noosfero.identifier_format}/
78 78  
79 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 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 85 # map balloon
86 86 match 'map_balloon/:action/:id', :controller => 'map_balloon', :id => /.*/
87 87  
88 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 92 ## Controllers that are profile-specific (for profile admins )
94 93 ######################################################
95 94 # profile customization - "My profile"
96 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 100 ## Controllers that are used by environment admin
102 101 ######################################################
103 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 110 ######################################################
112 111 # administrative tasks for a environment
113 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 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 3 class RoutingTest < ActionController::IntegrationTest
4 4  
... ... @@ -74,14 +74,14 @@ class RoutingTest &lt; ActionController::IntegrationTest
74 74 def test_content_viewer
75 75  
76 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 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 81 end
82 82  
83 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 85 end
86 86  
87 87 #FIXME remove this if design_blocks is not going to be used; or uncomment otherwise;
... ... @@ -127,19 +127,19 @@ class RoutingTest &lt; ActionController::IntegrationTest
127 127 end
128 128  
129 129 def test_search_routing
130   - assert_routing('/search', :controller => 'search', :action => 'index', :category_path => [])
  130 + assert_routing('/search', :controller => 'search', :action => 'index')
131 131 end
132 132  
133 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 135 end
136 136  
137 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 139 end
140 140  
141 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 143 end
144 144  
145 145 def test_content_view_with_dash
... ... @@ -147,11 +147,11 @@ class RoutingTest &lt; ActionController::IntegrationTest
147 147 end
148 148  
149 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 151 end
152 152  
153 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 155 end
156 156  
157 157 def test_catalog_routing
... ... @@ -229,31 +229,31 @@ class RoutingTest &lt; ActionController::IntegrationTest
229 229 end
230 230  
231 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 233 end
234 234  
235 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 237 end
238 238  
239 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 241 end
242 242  
243 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 245 end
246 246  
247 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 249 end
250 250  
251 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 253 end
254 254  
255 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 257 end
258 258  
259 259 end
... ...