1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix namespaced redirects [#4389 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
Andrew White 2010-06-24 11:48:05 +01:00 committed by José Valim
parent 176c386409
commit df15ba7ead
2 changed files with 15 additions and 1 deletions

View file

@ -55,7 +55,7 @@ module ActionDispatch
path = args.first
end
if @scope[:module] && options[:to]
if @scope[:module] && options[:to] && !options[:to].is_a?(Proc)
if options[:to].to_s.include?("#")
options[:to] = "#{@scope[:module]}/#{options[:to]}"
elsif @scope[:controller].nil?

View file

@ -300,6 +300,11 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
match '/' => 'mes#index'
end
namespace :private do
root :to => redirect('/private/index')
match "index", :to => 'private#index'
end
match "whatever/:controller(/:action(/:id))"
resource :profile do
@ -421,6 +426,15 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
end
def test_namespace_redirect
with_test_routes do
get '/private'
assert_equal 301, @response.status
assert_equal 'http://www.example.com/private/index', @response.headers['Location']
assert_equal 'Moved Permanently', @response.body
end
end
def test_session_singleton_resource
with_test_routes do
get '/session'