Essentially generates a modified Tempfile object similar to the object you’d get from the standard library CGI module in a multipart request. This means you can use an ActionController::TestUploadedFile object in the params of a test request in order to simulate a file upload.

Usage example, within a functional test:

  post :change_avatar, :avatar => ActionController::TestUploadedFile.new(Test::Unit::TestCase.fixture_path + '/files/spongebob.png', 'image/png')
Methods
Attributes
[R] content_type The content type of the "uploaded" file
[R] original_filename The filename, not including the path, of the "uploaded" file
Public Class methods
new(path, content_type = 'text/plain')
     # File vendor/rails/actionpack/lib/action_controller/test_process.rb, line 311
311:     def initialize(path, content_type = 'text/plain')
312:       raise "file does not exist" unless File.exist?(path)
313:       @content_type = content_type
314:       @original_filename = path.sub(/^.*#{File::SEPARATOR}([^#{File::SEPARATOR}]+)$/) { $1 }
315:       @tempfile = Tempfile.new(@original_filename)
316:       FileUtils.copy_file(path, @tempfile.path)
317:     end