diff options
-rw-r--r-- | actionpack/lib/action_controller/routing.rb | 1 | ||||
-rw-r--r-- | actionpack/test/controller/routing_tests.rb | 7 |
2 files changed, 7 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index 1f4d56ec01..1206fda5ec 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -176,6 +176,7 @@ module ActionController options = options.symbolize_keys defaults = request.path_parameters.symbolize_keys expand_controller_path!(options, defaults) + defaults.delete_if {|k, v| options.key?(k) && options[k].nil?} # Remove defaults that have been manually cleared using :name => nil failures = [] selected = nil diff --git a/actionpack/test/controller/routing_tests.rb b/actionpack/test/controller/routing_tests.rb index 69632c694f..91d7eedd21 100644 --- a/actionpack/test/controller/routing_tests.rb +++ b/actionpack/test/controller/routing_tests.rb @@ -185,7 +185,7 @@ class RouteTests < Test::Unit::TestCase assert_equal nil, @route.recognize([])[0] assert_equal nil, @route.recognize(%w{some_static route with more than expected})[0] end - + def test_basecamp route 'clients/', :controller => 'content' verify_generate('clients', {}, {:controller => 'content'}, {}) # Would like to have clients/ @@ -422,6 +422,11 @@ class RouteSetTests < Test::Unit::TestCase @set.connect ':action/:controller' verify_generate('index/content', options) end + + def test_default_dropped_with_nil_option + @request.path_parameters = {:controller => 'content', :action => 'action', :id => '10'} + verify_generate 'content/action', {:id => nil} + end end #require '../assertions/action_pack_assertions.rb' |