aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
authorYehuda Katz <wycats@gmail.com>2009-01-02 22:16:48 -0800
committerYehuda Katz <wycats@gmail.com>2009-01-02 22:16:48 -0800
commita38c749d8b5fd020d7294ffb4d597d4ab3fb30db (patch)
treee841f423d995c4720576151a1e1d7215ff8ad92c /actionpack/test/controller
parent42b32938d99d8f930e3020659ec0619aa5205c05 (diff)
downloadrails-a38c749d8b5fd020d7294ffb4d597d4ab3fb30db.tar.gz
rails-a38c749d8b5fd020d7294ffb4d597d4ab3fb30db.tar.bz2
rails-a38c749d8b5fd020d7294ffb4d597d4ab3fb30db.zip
Sync 'rails/rails/master'
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/dispatcher_test.rb5
-rw-r--r--actionpack/test/controller/integration_upload_test.rb46
-rw-r--r--actionpack/test/controller/rescue_test.rb7
3 files changed, 43 insertions, 15 deletions
diff --git a/actionpack/test/controller/dispatcher_test.rb b/actionpack/test/controller/dispatcher_test.rb
index da87d26146..7cd4e71aa1 100644
--- a/actionpack/test/controller/dispatcher_test.rb
+++ b/actionpack/test/controller/dispatcher_test.rb
@@ -32,11 +32,6 @@ class DispatcherTest < Test::Unit::TestCase
dispatch(false)
end
- def test_clears_asset_tag_cache_before_dispatch_if_in_loading_mode
- ActionView::Helpers::AssetTagHelper::AssetTag::Cache.expects(:clear).once
- dispatch(false)
- end
-
def test_leaves_dependencies_after_dispatch_if_not_in_loading_mode
ActionController::Routing::Routes.expects(:reload).never
ActiveSupport::Dependencies.expects(:clear).never
diff --git a/actionpack/test/controller/integration_upload_test.rb b/actionpack/test/controller/integration_upload_test.rb
index 39d2e164e4..d579980c19 100644
--- a/actionpack/test/controller/integration_upload_test.rb
+++ b/actionpack/test/controller/integration_upload_test.rb
@@ -10,6 +10,10 @@ class UploadTestController < ActionController::Base
SessionUploadTest.last_request_type = ActionController::Base.param_parsers[request.content_type]
render :text => "got here"
end
+
+ def read
+ render :text => "File: #{params[:uploaded_data].read}"
+ end
end
class SessionUploadTest < ActionController::IntegrationTest
@@ -19,21 +23,43 @@ class SessionUploadTest < ActionController::IntegrationTest
attr_accessor :last_request_type
end
- # def setup
- # @session = ActionController::Integration::Session.new
- # end
- def test_post_with_upload
- uses_mocha "test_post_with_upload" do
- ActiveSupport::Dependencies.stubs(:load?).returns(false)
+ def test_upload_and_read_file
+ with_test_routing do
+ post '/read', :uploaded_data => fixture_file_upload(FILES_DIR + "/hello.txt", "text/plain")
+ assert_equal "File: Hello", response.body
+ end
+ end
+
+ # The lint wrapper is used in integration tests
+ # instead of a normal StringIO class
+ InputWrapper = Rack::Lint::InputWrapper
+
+ def test_post_with_upload_with_unrewindable_input
+ InputWrapper.any_instance.expects(:rewind).raises(Errno::ESPIPE)
+
+ with_test_routing do
+ post '/read', :uploaded_data => fixture_file_upload(FILES_DIR + "/hello.txt", "text/plain")
+ assert_equal "File: Hello", response.body
+ end
+ end
+
+ def test_post_with_upload_with_params_parsing
+ with_test_routing do
+ params = { :uploaded_data => fixture_file_upload(FILES_DIR + "/mona_lisa.jpg", "image/jpg") }
+ post '/update', params, :location => 'blah'
+ assert_equal(:multipart_form, SessionUploadTest.last_request_type)
+ end
+ end
+
+ private
+ def with_test_routing
with_routing do |set|
set.draw do |map|
map.update 'update', :controller => "upload_test", :action => "update", :method => :post
+ map.read 'read', :controller => "upload_test", :action => "read", :method => :post
end
- params = { :uploaded_data => fixture_file_upload(FILES_DIR + "/mona_lisa.jpg", "image/jpg") }
- post '/update', params, :location => 'blah'
- assert_equal(:multipart_form, SessionUploadTest.last_request_type)
+ yield
end
end
- end
end
diff --git a/actionpack/test/controller/rescue_test.rb b/actionpack/test/controller/rescue_test.rb
index d45ba3c3a1..8728c9fca3 100644
--- a/actionpack/test/controller/rescue_test.rb
+++ b/actionpack/test/controller/rescue_test.rb
@@ -390,6 +390,13 @@ class RescueControllerTest < ActionController::TestCase
assert_equal "no way", @response.body
end
+ def test_rescue_dispatcher_exceptions_without_request_set
+ @request.env['REQUEST_URI'] = '/no_way'
+ response = RescueController.call_with_exception(@request.env, ActionController::RoutingError.new("Route not found"))
+ assert_kind_of ActionController::Response, response
+ assert_equal "no way", response.body
+ end
+
protected
def with_all_requests_local(local = true)
old_local, ActionController::Base.consider_all_requests_local =