aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2006-06-16 03:22:09 +0000
committerRick Olson <technoweenie@gmail.com>2006-06-16 03:22:09 +0000
commit2f58a467e321871a1d16761b04e1a87a4052711d (patch)
tree5406fddc337b8237f1d74a7c413a6ab81307c226
parentc638d9401b0e0b12af597919430cbdc6241a4057 (diff)
downloadrails-2f58a467e321871a1d16761b04e1a87a4052711d.tar.gz
rails-2f58a467e321871a1d16761b04e1a87a4052711d.tar.bz2
rails-2f58a467e321871a1d16761b04e1a87a4052711d.zip
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
-rw-r--r--actionpack/test/controller/routing_test.rb29
1 files changed, 23 insertions, 6 deletions
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb
index 8838ba841e..b2c3ebf410 100644
--- a/actionpack/test/controller/routing_test.rb
+++ b/actionpack/test/controller/routing_test.rb
@@ -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 \ No newline at end of file