From e3af27c51b3a7bb9dcbb45bce07c029ba019eba3 Mon Sep 17 00:00:00 2001 From: Nicholas Seckar Date: Thu, 7 Jul 2005 19:23:35 +0000 Subject: Improved testing of functional test setup. Fixed functional test setup so that :controller and :action are stored into path_parameters using string keys. Added with_routing test helper which can be used to dynamically replace the current set of routes inside a unit test. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1763 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/controller/test_test.rb | 40 ++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb index 996c3c6cc2..201fe03b44 100644 --- a/actionpack/test/controller/test_test.rb +++ b/actionpack/test/controller/test_test.rb @@ -114,10 +114,44 @@ HTML ) end - def test_path_params_are_strings + def test_id_converted_to_string get :test_params, :id => 20, :foo => Object.new - @request.path_parameters.each do |key, value| - assert_kind_of String, value + assert_kind_of String, @request.path_parameters['id'] + end + + def test_array_path_parameter_handled_properly + with_routing do |set| + set.draw do + set.connect 'file/*path', :controller => 'test_test/test', :action => 'test_params' + set.connect ':controller/:action/:id' + end + + get :test_params, :path => ['hello', 'world'] + assert_equal ['hello', 'world'], @request.path_parameters['path'] + assert_equal 'hello/world', @request.path_parameters['path'].to_s + end + end + + def test_assert_realistic_path_parameters + get :test_params, :id => 20, :foo => Object.new + + # All elements of path_parameters should use string keys + @request.path_parameters.keys.each do |key| + assert_kind_of String, key + end + end + + def test_with_routing_places_routes_back + assert ActionController::Routing::Routes + routes_id = ActionController::Routing::Routes.object_id + + begin + with_routing { raise 'fail' } + fail 'Should not be here.' + rescue RuntimeError end + + assert ActionController::Routing::Routes + assert_equal routes_id, ActionController::Routing::Routes.object_id end end -- cgit v1.2.3