Permalink
Browse files

Fix namespaced redirects [#4389 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent 176c386 commit df15ba7eadb180626474161741f901e675f517ce @pixeltrix pixeltrix committed with josevalim Jun 24, 2010
Showing with 15 additions and 1 deletion.
  1. +1 −1 actionpack/lib/action_dispatch/routing/mapper.rb
  2. +14 −0 actionpack/test/dispatch/routing_test.rb
@@ -55,7 +55,7 @@ def extract_path_and_options(args)
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?
@@ -300,6 +300,11 @@ def self.matches?(request)
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 @@ def test_logout_redirect_without_to
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'

0 comments on commit df15ba7

Please sign in to comment.