aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/routing_test.rb
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2010-06-26 10:46:24 +0100
committerJosé Valim <jose.valim@gmail.com>2010-06-26 12:02:29 +0200
commitd4e1a2ef0d35f322803284a980575fc31ff7b4b6 (patch)
tree48572a2b98f1c7453d7ec54d85ffcd6aafa4357c /actionpack/test/dispatch/routing_test.rb
parent59b24ceb0c558715714e272737ca0ca06f6043d5 (diff)
downloadrails-d4e1a2ef0d35f322803284a980575fc31ff7b4b6.tar.gz
rails-d4e1a2ef0d35f322803284a980575fc31ff7b4b6.tar.bz2
rails-d4e1a2ef0d35f322803284a980575fc31ff7b4b6.zip
Support optional static segements as well [#4832 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack/test/dispatch/routing_test.rb')
-rw-r--r--actionpack/test/dispatch/routing_test.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 719323a85c..cf92b039e3 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -312,6 +312,12 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "/groups(/user/:username)" => "groups#index"
get "(/user/:username)/photos" => "photos#index"
+ scope '(groups)' do
+ scope '(discussions)' do
+ resources :messages
+ end
+ end
+
match "whatever/:controller(/:action(/:id))"
resource :profile do
@@ -1512,6 +1518,34 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
end
+ def test_url_recognition_for_optional_static_segments
+ with_test_routes do
+ get '/groups/discussions/messages'
+ assert_equal 'messages#index', @response.body
+
+ get '/groups/discussions/messages/1'
+ assert_equal 'messages#show', @response.body
+
+ get '/groups/messages'
+ assert_equal 'messages#index', @response.body
+
+ get '/groups/messages/1'
+ assert_equal 'messages#show', @response.body
+
+ get '/discussions/messages'
+ assert_equal 'messages#index', @response.body
+
+ get '/discussions/messages/1'
+ assert_equal 'messages#show', @response.body
+
+ get '/messages'
+ assert_equal 'messages#index', @response.body
+
+ get '/messages/1'
+ assert_equal 'messages#show', @response.body
+ end
+ end
+
private
def with_test_routes
yield