From 9b424f04cac9a0fc62053f092775f8f36024a35a Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 4 Sep 2006 04:03:57 +0000 Subject: test_test deprecation and cosmetics git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4967 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/controller/test_test.rb | 46 +++++++++++++++++---------------- 1 file changed, 24 insertions(+), 22 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb index 1eda834351..29584ac201 100644 --- a/actionpack/test/controller/test_test.rb +++ b/actionpack/test/controller/test_test.rb @@ -15,8 +15,8 @@ class TestTest < Test::Unit::TestCase def test_params render :text => params.inspect - end - + end + def test_uri render :text => request.request_uri end @@ -41,7 +41,7 @@ class TestTest < Test::Unit::TestCase HTML end - + def test_only_one_param render :text => (params[:left] && params[:right]) ? "EEP, Both here!" : "OK" end @@ -49,7 +49,7 @@ HTML def test_remote_addr render :text => (request.remote_addr || "not specified") end - + def test_file_upload render :text => params[:file].size end @@ -99,8 +99,8 @@ HTML def test_process_without_flash process :set_flash assert_equal '><', flash['test'] - end - + end + def test_process_with_flash process :set_flash, nil, nil, { "test" => "value" } assert_equal '>value<', flash['test'] @@ -120,12 +120,12 @@ HTML @request.set_REQUEST_URI "/explicit/uri" process :test_uri, :id => 7 assert_equal "/explicit/uri", @response.body - end - - def test_multiple_calls + end + + def test_multiple_calls process :test_only_one_param, :left => true assert_equal "OK", @response.body - process :test_only_one_param, :right => true + process :test_only_one_param, :right => true assert_equal "OK", @response.body end @@ -243,7 +243,7 @@ HTML process :test_html_output # there is a tag containing only one child with an id of 'foo' - assert_tag :children => { :count => 1, + assert_tag :children => { :count => 1, :only => { :attributes => { :id => "foo" } } } # there is no tag containing only one 'li' child assert_no_tag :children => { :count => 1, :only => { :tag => "li" } } @@ -257,7 +257,7 @@ HTML # the output does not contain the string "test" assert_no_tag :content => "test" end - + def test_assert_tag_multiple process :test_html_output @@ -277,7 +277,7 @@ HTML def test_assert_tag_children_without_content process :test_html_output - + # there is a form tag with an 'input' child which is a self closing tag assert_tag :tag => "form", :children => { :count => 1, @@ -324,7 +324,7 @@ HTML map.connect 'file/*path', :controller => 'test_test/test', :action => 'test_params' map.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 @@ -343,13 +343,13 @@ HTML 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 @@ -390,33 +390,35 @@ HTML end end end - + FILES_DIR = File.dirname(__FILE__) + '/../fixtures/multipart' - + def test_test_uploaded_file filename = 'mona_lisa.jpg' path = "#{FILES_DIR}/#{filename}" content_type = 'image/png' - + file = ActionController::TestUploadedFile.new(path, content_type) assert_equal filename, file.original_filename assert_equal content_type, file.content_type assert_equal file.path, file.local_path assert_equal File.read(path), file.read end - + def test_fixture_file_upload post :test_file_upload, :file => fixture_file_upload(FILES_DIR + "/mona_lisa.jpg", "image/jpg") assert_equal 159528, @response.body end - + def test_test_uploaded_file_exception_when_file_doesnt_exist assert_raise(RuntimeError) { ActionController::TestUploadedFile.new('non_existent_file') } end def test_assert_redirected_to_symbol with_foo_routing do |set| - get :redirect_to_symbol + assert_deprecated(/generate_url.*redirect_to/) do + get :redirect_to_symbol + end assert_response :redirect assert_redirected_to :generate_url end -- cgit v1.2.3