add passing test to make sure unhandled requests don't load unnecessary classes. Closed #5408. [nkriege@hotmail.com]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4451 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Rick Olson 2006-06-16 03:22:09 +00:00
parent c638d9401b
commit 2f58a467e3
1 changed files with 23 additions and 6 deletions

View File

@ -842,24 +842,29 @@ class RouteTest < Test::Unit::TestCase
end
def test_simple_build_query_string
assert_equal '?x=1&y=2', @route.build_query_string(:x => '1', :y => '2')
assert_equal '?x=1&y=2', order_query_string(@route.build_query_string(:x => '1', :y => '2'))
end
def test_convert_ints_build_query_string
assert_equal '?x=1&y=2', @route.build_query_string(:x => 1, :y => 2)
assert_equal '?x=1&y=2', order_query_string(@route.build_query_string(:x => 1, :y => 2))
end
def test_escape_spaces_build_query_string
assert_equal '?x=hello+world&y=goodbye+world', @route.build_query_string(:x => 'hello world', :y => 'goodbye world')
assert_equal '?x=hello+world&y=goodbye+world', order_query_string(@route.build_query_string(:x => 'hello world', :y => 'goodbye world'))
end
def test_expand_array_build_query_string
assert_equal '?x[]=1&x[]=2', @route.build_query_string(:x => [1, 2])
assert_equal '?x[]=1&x[]=2', order_query_string(@route.build_query_string(:x => [1, 2]))
end
def test_escape_spaces_build_query_string_selected_keys
assert_equal '?x=hello+world', @route.build_query_string({:x => 'hello world', :y => 'goodbye world'}, [:x])
assert_equal '?x=hello+world', order_query_string(@route.build_query_string({:x => 'hello world', :y => 'goodbye world'}, [:x]))
end
private
def order_query_string(qs)
'?' + qs[1..-1].split('&').sort.join('&')
end
end
class RouteBuilderTest < Test::Unit::TestCase
@ -1301,6 +1306,18 @@ class RouteSetTest < Test::Unit::TestCase
Object.send(:remove_const, :ArticlesController)
end
def test_routing_traversal_does_not_load_extra_classes
assert !Object.const_defined?("Profiler__"), "Profiler should not be loaded"
set.draw do |map|
map.connect '/profile', :controller => 'profile'
end
request.path = '/profile'
set.recognize(request) rescue nil
assert !Object.const_defined?("Profiler__"), "Profiler should not be loaded"
end
def test_recognize_with_conditions_and_format
Object.const_set(:PeopleController, Class.new)
@ -1455,4 +1472,4 @@ class RoutingTest < Test::Unit::TestCase
paths = ActionController::Routing.normalize_paths(load_paths)
assert_equal %w(vendor\\rails\\railties\\builtin\\rails_info vendor\\rails\\actionpack\\lib app\\controllers app\\helpers app\\models lib .), paths
end
end
end