From d086b4eab7aa4179637aa6d18ab7fc3bf3258d81 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Mon, 8 Mar 2010 16:50:29 +0100 Subject: [PATCH] failing test for :defaults in routing not being passed through to path_parameters --- actionpack/test/dispatch/routing_test.rb | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index b46276c..95b6e9b 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -149,6 +149,8 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest match '/info' => 'projects#info', :as => 'info' + match '/defaults' => 'projects#info', :as => 'defaults', :defaults => { :format => 'json' } + namespace :admin do scope '(:locale)', :locale => /en|pl/ do resources :descriptions @@ -738,6 +740,13 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest end end + def test_defaults + with_test_routes do + get '/defaults' + assert_equal 'json', @request.env['action_dispatch.request.path_parameters'][:format] + end + end + private def with_test_routes yield -- 1.6.0.2 From 8e6cd51e7e357c7ff7c608f55d2608eadc17e407 Mon Sep 17 00:00:00 2001 From: Jeroen van Dijk Date: Mon, 8 Mar 2010 17:49:25 +0100 Subject: [PATCH] Merge in provided route defaults Fix for https://rails.lighthouseapp.com/projects/16213/tickets/119-default-route-option-doesnt-work --- actionpack/lib/action_dispatch/routing/mapper.rb | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 7a33259..b21c1cf 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -115,7 +115,7 @@ module ActionDispatch raise ArgumentError, "missing :action" end - defaults + defaults.merge(@options[:defaults] || {}) end end -- 1.6.0.2