aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/routing_test.rb
diff options
context:
space:
mode:
authorbrainopia <brainopia@evilmartians.com>2014-12-27 13:42:42 +0300
committerbrainopia <brainopia@evilmartians.com>2015-01-25 03:07:27 +0300
commit572bbab2e63916b4bb5e835d403856767b7f4be5 (patch)
treeea971378864f33ceb33d84a6a232405fa21eaa30 /actionpack/test/dispatch/routing_test.rb
parent04d1c3716b5bfa133a0b1ed937649a0829ac5f22 (diff)
downloadrails-572bbab2e63916b4bb5e835d403856767b7f4be5.tar.gz
rails-572bbab2e63916b4bb5e835d403856767b7f4be5.tar.bz2
rails-572bbab2e63916b4bb5e835d403856767b7f4be5.zip
Improve shorthand matching for routes
Shorthand route match is when controller and action are taken literally from path. E.g. get '/foo/bar' # => will use 'foo#bar' as endpoint get '/foo/bar/baz' # => will use 'foo/bar#baz' as endpoint Not any path with level two or more of nesting can be used as shortcut. If path contains any characters outside of /[\w-]/ then it can't be used as such. This commit ensures that invalid shortcuts aren't used. ':controller/:action/postfix' - is an example of invalid shortcut that was previosly matched and led to exception: "ArgumentError - ':controller/:action' is not a supported controller name"
Diffstat (limited to 'actionpack/test/dispatch/routing_test.rb')
-rw-r--r--actionpack/test/dispatch/routing_test.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 3373705326..57cdecfb8a 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -1430,6 +1430,15 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
assert_equal 'api/v3/products#list', @response.body
end
+ def test_not_matching_shorthand_with_dynamic_parameters
+ draw do
+ get ':controller/:action/admin'
+ end
+
+ get '/finances/overview/admin'
+ assert_equal 'finances#overview', @response.body
+ end
+
def test_controller_option_with_nesting_and_leading_slash
draw do
scope '/job', controller: 'job' do