From 3d746fcdb584767c476408f395320e934fd5383e Mon Sep 17 00:00:00 2001 From: Andrew White Date: Fri, 26 Mar 2010 12:16:25 +0000 Subject: Add parameter defaults support to new routing DSL [#4265 state:resolved] Signed-off-by: wycats --- actionpack/test/dispatch/routing_test.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'actionpack/test/dispatch/routing_test.rb') diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index 87a46feec7..cbe9b5488c 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -121,6 +121,13 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest # misc match 'articles/:year/:month/:day/:title', :to => "articles#show", :as => :article + # default params + match 'inline_pages/(:id)', :to => 'pages#show', :id => 'home' + match 'default_pages/(:id)', :to => 'pages#show', :defaults => { :id => 'home' } + defaults :id => 'home' do + match 'scoped_pages/(:id)', :to => 'pages#show' + end + namespace :account do match 'shorthand' match 'description', :to => "account#description", :as => "description" @@ -769,6 +776,19 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest end end + def test_default_params + with_test_routes do + get '/inline_pages' + assert_equal 'home', @request.params[:id] + + get '/default_pages' + assert_equal 'home', @request.params[:id] + + get '/scoped_pages' + assert_equal 'home', @request.params[:id] + end + end + private def with_test_routes yield -- cgit v1.2.3