aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2008-03-03 06:42:24 +0000
committerMichael Koziarski <michael@koziarski.com>2008-03-03 06:42:24 +0000
commitcc5a957d2b57b1d7081abd6939396f32e7b4b204 (patch)
tree9ab8292c0358c19963cd47fbeddd2b2e939b7ba7 /actionpack/test/controller
parent4ca170fcea17ca0cd52677c39e865a0934ecd7d3 (diff)
downloadrails-cc5a957d2b57b1d7081abd6939396f32e7b4b204.tar.gz
rails-cc5a957d2b57b1d7081abd6939396f32e7b4b204.tar.bz2
rails-cc5a957d2b57b1d7081abd6939396f32e7b4b204.zip
Allow file uploads in Integration Tests. Closes #11091 [RubyRedRick]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8978 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/integration_upload_test.rb47
1 files changed, 47 insertions, 0 deletions
diff --git a/actionpack/test/controller/integration_upload_test.rb b/actionpack/test/controller/integration_upload_test.rb
new file mode 100644
index 0000000000..0968ae6845
--- /dev/null
+++ b/actionpack/test/controller/integration_upload_test.rb
@@ -0,0 +1,47 @@
+require 'abstract_unit'
+require 'action_controller/integration'
+require 'action_controller/routing'
+
+unless defined? ApplicationController
+ class ApplicationController < ActionController::Base
+ end
+end
+
+class UploadTestController < ActionController::Base
+ session :off
+
+ def update
+ SessionUploadTest.last_request_type = ActionController::Base.param_parsers[request.content_type]
+ render :text => "got here"
+ end
+end
+
+class SessionUploadTest < ActionController::IntegrationTest
+ FILES_DIR = File.dirname(__FILE__) + '/../fixtures/multipart'
+
+ class << self
+ 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
+ Dependencies.stubs(:load?).returns(false)
+ with_routing do |set|
+ set.draw do |map|
+ map.update 'update', :controller => "upload_test", :action => "update", :method => :post
+ end
+ path = "/update"
+ params = {:uploaded_data => fixture_file_upload(FILES_DIR + "/mona_lisa.jpg", "image/jpg")}
+ headers = {:location => 'blah' }
+ post(path,params,headers)
+ assert_equal(:multipart_form, SessionUploadTest.last_request_type)
+ end
+ end
+
+ end
+end \ No newline at end of file