Fixed routing bug #1592

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1645 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson
2005-07-03 12:01:06 +00:00
parent 208291391c
commit 5524dedc06
2 changed files with 5 additions and 0 deletions

View File

@@ -360,10 +360,12 @@ module ActionController
def generate(options, request_or_recall_hash = {})
recall = request_or_recall_hash.is_a?(Hash) ? request_or_recall_hash : request_or_recall_hash.symbolized_path_parameters
use_recall = true
controller = options[:controller]
recall_controller = recall[:controller]
if (recall_controller && recall_controller.include?(?/)) || (controller && controller.include?(?/))
recall = {} if controller && controller[0] == ?/
options[:controller] = Routing.controller_relative_to(controller, recall_controller)
end
options = recall.dup if options.empty? # XXX move to url_rewriter?

View File

@@ -573,6 +573,9 @@ class RouteSetTests < Test::Unit::TestCase
assert_equal ['/admin/user/show', {}], rs.generate({:action => 'show'}, {:controller => 'admin/user', :action => 'list', :id => '10'})
assert_equal ['/admin/user/list/10', {}], rs.generate({}, {:controller => 'admin/user', :action => 'list', :id => '10'})
assert_equal ['/admin/stuff', {}], rs.generate({:controller => 'stuff'}, {:controller => 'admin/user', :action => 'list', :id => '10'})
assert_equal ['/stuff', {}], rs.generate({:controller => '/stuff'}, {:controller => 'admin/user', :action => 'list', :id => '10'})
end
def test_ignores_leading_slash