diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-04-24 20:24:03 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-04-24 20:24:54 -0500 |
commit | dd2ed32418a74ca9126834f98a1b0bca926c0c4f (patch) | |
tree | 5a9983b3c83148fd7bac98cdaee18355cd3a37aa /actionpack/lib/action_controller/testing/process.rb | |
parent | cbcc0ca57b0ea713d7d32364b599d88f2bef6d92 (diff) | |
download | rails-dd2ed32418a74ca9126834f98a1b0bca926c0c4f.tar.gz rails-dd2ed32418a74ca9126834f98a1b0bca926c0c4f.tar.bz2 rails-dd2ed32418a74ca9126834f98a1b0bca926c0c4f.zip |
Start to integrate some of the features in Rack::Test.
Eventually commit ActionDispatch::Test::MockRequest and ActionDispatch::Test:: UploadedFile upstream.
Diffstat (limited to 'actionpack/lib/action_controller/testing/process.rb')
-rw-r--r-- | actionpack/lib/action_controller/testing/process.rb | 29 |
1 files changed, 1 insertions, 28 deletions
diff --git a/actionpack/lib/action_controller/testing/process.rb b/actionpack/lib/action_controller/testing/process.rb index 7e2857614c..f5742af472 100644 --- a/actionpack/lib/action_controller/testing/process.rb +++ b/actionpack/lib/action_controller/testing/process.rb @@ -363,34 +363,7 @@ module ActionController #:nodoc: # # Pass a true third parameter to ensure the uploaded file is opened in binary mode (only required for Windows): # post :change_avatar, :avatar => ActionController::TestUploadedFile.new(ActionController::TestCase.fixture_path + '/files/spongebob.png', 'image/png', :binary) - require 'tempfile' - class TestUploadedFile - # The filename, *not* including the path, of the "uploaded" file - attr_reader :original_filename - - # The content type of the "uploaded" file - attr_accessor :content_type - - def initialize(path, content_type = Mime::TEXT, binary = false) - raise "#{path} file does not exist" unless File.exist?(path) - @content_type = content_type - @original_filename = path.sub(/^.*#{File::SEPARATOR}([^#{File::SEPARATOR}]+)$/) { $1 } - @tempfile = Tempfile.new(@original_filename) - @tempfile.set_encoding(Encoding::BINARY) if @tempfile.respond_to?(:set_encoding) - @tempfile.binmode if binary - FileUtils.copy_file(path, @tempfile.path) - end - - def path #:nodoc: - @tempfile.path - end - - alias local_path path - - def method_missing(method_name, *args, &block) #:nodoc: - @tempfile.__send__(method_name, *args, &block) - end - end + TestUploadedFile = ActionDispatch::Test::UploadedFile module TestProcess def self.included(base) |