aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-05-29 10:55:59 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-05-29 10:55:59 -0700
commit8ed1a562c6293c81c894f3fe55fe88610c4f6caa (patch)
tree46c5d96d51f5f1d89d0a2802545400d59438fa06
parent7e61a327ce0fdb4b98a76d318ca0b5ffee0be7de (diff)
downloadrails-8ed1a562c6293c81c894f3fe55fe88610c4f6caa.tar.gz
rails-8ed1a562c6293c81c894f3fe55fe88610c4f6caa.tar.bz2
rails-8ed1a562c6293c81c894f3fe55fe88610c4f6caa.zip
"controllers" should be a valid path name
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb2
-rw-r--r--actionpack/test/dispatch/routing_test.rb10
2 files changed, 11 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 0a1f6afd77..67e7285dcd 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -117,7 +117,7 @@ module ActionDispatch
options[$1.to_sym] ||= /.+?/
end
- if path_without_format.match(':controller')
+ if path_pattern.names.map(&:to_sym).include?(:controller)
raise ArgumentError, ":controller segment is not allowed within a namespace block" if scope[:module]
# Add a default constraint for :controller path segments that matches namespaced
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 8249403a65..d6477e19bb 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -99,6 +99,16 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
end
+ def test_namespace_without_controller_segment
+ draw do
+ namespace :admin do
+ get 'hello/:controllers/:action'
+ end
+ end
+ get '/admin/hello/foo/new'
+ assert_equal 'foo', @request.params["controllers"]
+ end
+
def test_session_singleton_resource
draw do
resource :session do