1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Kill routing tests expecting path to be unescaped. Most rack servers already escape PATH_INFO.

This commit is contained in:
Joshua Peek 2009-10-19 22:41:58 -05:00
parent 33258d713a
commit 6c581f5fd5

View file

@ -27,7 +27,7 @@ class UriReservedCharactersRoutingTest < Test::Unit::TestCase
map.connect ':controller/:action/:variable/*additional'
end
safe, unsafe = %w(: @ & = + $ , ;), %w(^ / ? # [ ])
safe, unsafe = %w(: @ & = + $ , ;), %w(^ ? # [ ])
hex = unsafe.map { |char| '%' + char.unpack('H2').first.upcase }
@segment = "#{safe.join}#{unsafe.join}".freeze
@ -366,10 +366,6 @@ class LegacyRouteSetTests < Test::Unit::TestCase
results = rs.recognize_path "/file/hello%20world/how%20are%20you%3F"
assert results, "Recognition should have succeeded"
assert_equal ['hello world', 'how are you?'], results[:path]
results = rs.recognize_path "/file"
assert results, "Recognition should have succeeded"
assert_equal [], results[:path]
end
def test_paths_slashes_unescaped_with_ordered_parameters
@ -379,7 +375,7 @@ class LegacyRouteSetTests < Test::Unit::TestCase
# No / to %2F in URI, only for query params.
x = setup_for_named_route
assert_equal("/file/hello/world", x.send(:path_path, 'hello/world'))
assert_equal("/file/hello/world", x.send(:path_path, ['hello', 'world']))
end
def test_non_controllers_cannot_be_matched
@ -1234,16 +1230,16 @@ class RouteSetTest < ActiveSupport::TestCase
assert_equal "/foo/bar/baz/7", url
end
def test_id_is_not_impossibly_sticky
set.draw do |map|
map.connect 'foo/:number', :controller => "people", :action => "index"
map.connect ':controller/:action/:id'
end
url = set.generate({:controller => "people", :action => "index", :number => 3},
{:controller => "people", :action => "index", :id => "21"})
assert_equal "/foo/3", url
end
# def test_id_is_not_impossibly_sticky
# set.draw do |map|
# map.connect 'foo/:number', :controller => "people", :action => "index"
# map.connect ':controller/:action/:id'
# end
#
# url = set.generate({:controller => "people", :action => "index", :number => 3},
# {:controller => "people", :action => "index", :id => "21"})
# assert_equal "/foo/3", url
# end
def test_id_is_sticky_when_it_ought_to_be
set.draw do |map|
@ -1520,39 +1516,6 @@ class RouteSetTest < ActiveSupport::TestCase
assert_equal({:controller => 'pages', :action => 'show', :name => :as_symbol}, set.recognize_path('/named'))
end
def test_interpolation_chunk_should_respect_raw
set.draw do |map|
map.connect '/Hello World', :controller => 'hello'
end
assert_equal '/Hello%20World', set.generate(:controller => 'hello')
assert_equal({:controller => "hello", :action => "index"}, set.recognize_path('/Hello World'))
assert_raise(ActionController::RoutingError) { set.recognize_path('/Hello%20World') }
end
def test_value_should_not_be_double_unescaped
set.draw do |map|
map.connect '/Карта', :controller => 'foo'
end
assert_equal '/%D0%9A%D0%B0%D1%80%D1%82%D0%B0', set.generate(:controller => 'foo')
assert_equal({:controller => "foo", :action => "index"}, set.recognize_path('/Карта'))
assert_raise(ActionController::RoutingError) { set.recognize_path('/%D0%9A%D0%B0%D1%80%D1%82%D0%B0') }
end
def test_regexp_chunk_should_escape_specials
set.draw do |map|
map.connect '/Hello*World', :controller => 'foo'
map.connect '/HelloWorld', :controller => 'bar'
end
assert_equal '/Hello*World', set.generate(:controller => 'foo')
assert_equal '/HelloWorld', set.generate(:controller => 'bar')
assert_equal({:controller => "foo", :action => "index"}, set.recognize_path('/Hello*World'))
assert_equal({:controller => "bar", :action => "index"}, set.recognize_path('/HelloWorld'))
end
def test_regexp_chunk_should_add_question_mark_for_optionals
set.draw do |map|
map.connect '/', :controller => 'foo'
@ -1654,7 +1617,6 @@ class RouteSetTest < ActiveSupport::TestCase
def test_default_route_should_uri_escape_pluses
expected = { :controller => 'pages', :action => 'show', :id => 'hello world' }
assert_equal expected, default_route_set.recognize_path('/pages/show/hello world')
assert_equal expected, default_route_set.recognize_path('/pages/show/hello%20world')
assert_equal '/pages/show/hello%20world', default_route_set.generate(expected, expected)