diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-02-09 13:37:46 -0800 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-02-09 13:37:46 -0800 |
commit | 56f51888f1ba5833d0d2a7a89c5c6c4d7d2cd0b6 (patch) | |
tree | 6d423a91b2298d9908ec4ecb8261c15641c0a4f5 /actionpack | |
parent | 34238422b903ee832f8feec73801111768fb8d40 (diff) | |
parent | 9e10d591991e8e52488880f5c0d518590716d225 (diff) | |
download | rails-56f51888f1ba5833d0d2a7a89c5c6c4d7d2cd0b6.tar.gz rails-56f51888f1ba5833d0d2a7a89c5c6c4d7d2cd0b6.tar.bz2 rails-56f51888f1ba5833d0d2a7a89c5c6c4d7d2cd0b6.zip |
Merge pull request #9234 from senny/9231_no_numbers_in_route_namespaces_allowed
The `:controller` option for routes can contain numbers. closes #9231.
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 2 | ||||
-rw-r--r-- | actionpack/test/dispatch/routing_test.rb | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 34f5f80d4d..0a41ed0fcf 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -246,7 +246,7 @@ module ActionDispatch raise ArgumentError, "missing :action" end - if controller.is_a?(String) && controller !~ /\A[a-z_\/]+\z/ + if controller.is_a?(String) && controller !~ /\A[a-z_0-9\/]*\z/ message = "'#{controller}' is not a supported controller name. This can lead to potential routing problems." message << " See http://guides.rubyonrails.org/routing.html#specifying-a-controller-to-use" raise ArgumentError, message diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index fb1b8526d0..143733254b 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -1031,6 +1031,18 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest assert_equal 'users/home#index', @response.body end + def test_namespace_containing_numbers + draw do + namespace :v2 do + resources :subscriptions + end + end + + get '/v2/subscriptions' + assert_equal 'v2/subscriptions#index', @response.body + assert_equal '/v2/subscriptions', v2_subscriptions_path + end + def test_articles_with_id draw do controller :articles do |