Browse files

Clear route defaults using :name => nil #663

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@671 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 519fe7c commit 5760a6cb3e3f3ce3b41c25023f3fbb875590c5bc @dhh dhh committed Feb 18, 2005
Showing with 7 additions and 1 deletion.
  1. +1 −0 actionpack/lib/action_controller/routing.rb
  2. +6 −1 actionpack/test/controller/routing_tests.rb
View
1 actionpack/lib/action_controller/routing.rb
@@ -176,6 +176,7 @@ def generate(options, request)
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
View
7 actionpack/test/controller/routing_tests.rb
@@ -185,7 +185,7 @@ def test_requirements
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 @@ def test_action_dropped_when_controller_given
@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'

0 comments on commit 5760a6c

Please sign in to comment.