From 45ced7e1beb0d996f0471e21f0f88efaf2b26124 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 13 Oct 2011 18:50:23 -0700 Subject: Failing tests for path parameter escaping --- actionpack/test/dispatch/routing_test.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'actionpack/test/dispatch/routing_test.rb') diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index a71ac1bdc1..a0d2c51a7c 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -2528,3 +2528,30 @@ class TestHttpMethods < ActionDispatch::IntegrationTest end end end + +class TestUriPathEscaping < ActionDispatch::IntegrationTest + Routes = ActionDispatch::Routing::RouteSet.new.tap do |app| + app.draw do + match '/:segment' => lambda { |env| + path_params = env['action_dispatch.request.path_parameters'] + [200, { 'Content-Type' => 'text/plain' }, [path_params[:segment]]] + }, :as => :segment + end + end + + include Routes.url_helpers + def app; Routes end + + setup do + @path, @param = '/a%20b%2Fc+d', 'a b/c+d' + end + + test 'escapes generated path parameters' do + assert_equal @path, segment_path(:segment => @param) + end + + test 'unescapes recognized path parameters' do + get @path + assert_equal @param, @response.body + end +end -- cgit v1.2.3