Skip to content
This repository
Browse code

Failing tests for path parameter escaping

  • Loading branch information...
commit 45ced7e1beb0d996f0471e21f0f88efaf2b26124 1 parent a5b0f91
Jeremy Kemper authored October 13, 2011

Showing 1 changed file with 27 additions and 0 deletions. Show diff stats Hide diff stats

  1. 27  actionpack/test/dispatch/routing_test.rb
27  actionpack/test/dispatch/routing_test.rb
@@ -2528,3 +2528,30 @@ def simple_app(response)
2528 2528
     end
2529 2529
   end
2530 2530
 end
  2531
+
  2532
+class TestUriPathEscaping < ActionDispatch::IntegrationTest
  2533
+  Routes = ActionDispatch::Routing::RouteSet.new.tap do |app|
  2534
+    app.draw do
  2535
+      match '/:segment' => lambda { |env|
  2536
+        path_params = env['action_dispatch.request.path_parameters']
  2537
+        [200, { 'Content-Type' => 'text/plain' }, [path_params[:segment]]]
  2538
+      }, :as => :segment
  2539
+    end
  2540
+  end
  2541
+
  2542
+  include Routes.url_helpers
  2543
+  def app; Routes end
  2544
+
  2545
+  setup do
  2546
+    @path, @param = '/a%20b%2Fc+d', 'a b/c+d'
  2547
+  end
  2548
+
  2549
+  test 'escapes generated path parameters' do
  2550
+    assert_equal @path, segment_path(:segment => @param)
  2551
+  end
  2552
+
  2553
+  test 'unescapes recognized path parameters' do
  2554
+    get @path
  2555
+    assert_equal @param, @response.body
  2556
+  end
  2557
+end

0 notes on commit 45ced7e

Please sign in to comment.
Something went wrong with that request. Please try again.