From 73d8a90bee79106c965ad35151870941ab38d951 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 16 Jan 2014 10:07:51 +0100 Subject: Add failing test for #13369 After introducing 50311f1 a regression was introduced: routes with trailing slash are no longer recognized properly. This commit provides a failing test for this situation. --- actionpack/test/dispatch/routing_test.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'actionpack') diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index 5a532dc38f..795911497e 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -2894,6 +2894,24 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest assert_equal '/foo', foo_root_path end + def test_trailing_slash + draw do + resources :streams + end + + get '/streams' + assert @response.ok?, 'route without trailing slash should work' + + get '/streams/' + assert @response.ok?, 'route with trailing slash should work' + + get '/streams?foobar' + assert @response.ok?, 'route without trailing slash and with QUERY_STRING should work' + + get '/streams/?foobar' + assert @response.ok?, 'route with trailing slash and with QUERY_STRING should work' + end + private def draw(&block) -- cgit v1.2.3 From 2e0f9ed76eed8132ce49e672694a3d53baf38b6f Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 16 Jan 2014 10:13:05 +0100 Subject: Revert "Don't remove trailing slash from PATH_INFO for mounted apps" The revert is needed because of a regression described in #13369, routes with trailing slash are no longer recognized properly. This reverts commit 50311f1391ddd8e0349d74eb57f04b7e0045a27d. --- actionpack/CHANGELOG.md | 6 ------ actionpack/lib/action_dispatch/journey/router.rb | 8 +------- actionpack/test/dispatch/mount_test.rb | 5 ----- 3 files changed, 1 insertion(+), 18 deletions(-) (limited to 'actionpack') diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index dc98fb583c..24dc207656 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -431,10 +431,4 @@ *Piotr Sarnacki*, *Łukasz Strzałkowski* -* Fix removing trailing slash for mounted apps. - - Fixes #3215. - - *Piotr Sarnacki* - Please check [4-0-stable](https://github.com/rails/rails/blob/4-0-stable/actionpack/CHANGELOG.md) for previous changes. diff --git a/actionpack/lib/action_dispatch/journey/router.rb b/actionpack/lib/action_dispatch/journey/router.rb index da32f1bfe7..419e665d12 100644 --- a/actionpack/lib/action_dispatch/journey/router.rb +++ b/actionpack/lib/action_dispatch/journey/router.rb @@ -54,7 +54,7 @@ module ActionDispatch end def call(env) - env['PATH_INFO'] = normalize_path(env['PATH_INFO']) + env['PATH_INFO'] = Utils.normalize_path(env['PATH_INFO']) find_routes(env).each do |match, parameters, route| script_name, path_info, set_params = env.values_at('SCRIPT_NAME', @@ -103,12 +103,6 @@ module ActionDispatch private - def normalize_path(path) - path = "/#{path}" - path.squeeze!('/') - path - end - def partitioned_routes routes.partitioned_routes end diff --git a/actionpack/test/dispatch/mount_test.rb b/actionpack/test/dispatch/mount_test.rb index 683a4f01e2..cdf00d84fb 100644 --- a/actionpack/test/dispatch/mount_test.rb +++ b/actionpack/test/dispatch/mount_test.rb @@ -44,11 +44,6 @@ class TestRoutingMount < ActionDispatch::IntegrationTest "A named route should be defined with a parent's prefix" end - def test_trailing_slash_is_not_removed_from_path_info - get "/sprockets/omg/" - assert_equal "/sprockets -- /omg/", response.body - end - def test_mounting_sets_script_name get "/sprockets/omg" assert_equal "/sprockets -- /omg", response.body -- cgit v1.2.3