public Method

TestProcess.fixture_file_upload(path, mime_type = nil, binary = false)

Shortcut for ActionController::TestUploadedFile.new(Test::Unit::TestCase.fixture_path + path, type). Example:

post :change_avatar, :avatar => fixture_file_upload('/files/spongebob.png', 'image/png')

To upload binary files on Windows, pass :binary as the last parameter. This will not affect other platforms.

post :change_avatar, :avatar => fixture_file_upload('/files/spongebob.png', 'image/png', :binary)

Source Code

# File action_controller/test_process.rb, line 474
def fixture_file_upload(path, mime_type = nil, binary = false)
  ActionController::TestUploadedFile.new(
    Test::Unit::TestCase.respond_to?(:fixture_path) ? Test::Unit::TestCase.fixture_path + path : path, 
    mime_type,
    binary
  )
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.