Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix namespaced redirects [#4389 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
commit df15ba7eadb180626474161741f901e675f517ce 1 parent 176c386
@pixeltrix pixeltrix authored josevalim committed
View
2  actionpack/lib/action_dispatch/routing/mapper.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?
View
14 actionpack/test/dispatch/routing_test.rb
@@ -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'
Please sign in to comment.
Something went wrong with that request. Please try again.