aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2011-10-13 21:42:15 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2011-10-13 21:42:15 -0700
commit401d00d296c0c4dafd0e1103051f6adf0ae56fc5 (patch)
tree63bedd0152c9ecdca41b7a2018859691d297b8ba /actionpack/test/dispatch
parentbceec4c3c3c8bb8d0747e0c58fd539f46228c37b (diff)
downloadrails-401d00d296c0c4dafd0e1103051f6adf0ae56fc5.tar.gz
rails-401d00d296c0c4dafd0e1103051f6adf0ae56fc5.tar.bz2
rails-401d00d296c0c4dafd0e1103051f6adf0ae56fc5.zip
Symbol captures may generate multiple path segments, so don't escape / -> %2F. Test splat escaping.
Diffstat (limited to 'actionpack/test/dispatch')
-rw-r--r--actionpack/test/dispatch/routing_test.rb24
1 files changed, 17 insertions, 7 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index a0d2c51a7c..cf22731823 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -2536,22 +2536,32 @@ class TestUriPathEscaping < ActionDispatch::IntegrationTest
path_params = env['action_dispatch.request.path_parameters']
[200, { 'Content-Type' => 'text/plain' }, [path_params[:segment]]]
}, :as => :segment
+
+ match '/*splat' => lambda { |env|
+ path_params = env['action_dispatch.request.path_parameters']
+ [200, { 'Content-Type' => 'text/plain' }, [path_params[:splat]]]
+ }, :as => :splat
end
end
include Routes.url_helpers
def app; Routes end
- setup do
- @path, @param = '/a%20b%2Fc+d', 'a b/c+d'
+ test 'escapes generated path segment' do
+ assert_equal '/a%20b/c+d', segment_path(:segment => 'a b/c+d')
+ end
+
+ test 'unescapes recognized path segment' do
+ get '/a%20b%2Fc+d'
+ assert_equal 'a b/c+d', @response.body
end
- test 'escapes generated path parameters' do
- assert_equal @path, segment_path(:segment => @param)
+ test 'escapes generated path splat' do
+ assert_equal '/a%20b/c+d', splat_path(:splat => 'a b/c+d')
end
- test 'unescapes recognized path parameters' do
- get @path
- assert_equal @param, @response.body
+ test 'unescapes recognized path splat' do
+ get '/a%20b/c+d'
+ assert_equal 'a b/c+d', @response.body
end
end