Created
February 26, 2010 21:39
-
-
Save jtrupiano/316188 to your computer and use it in GitHub Desktop.
Add fixture_file_upload to factory_girl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'action_controller/test_process' | |
class Factory | |
module FixtureFileUpload | |
def fixture_file_upload(attr_name, path, mime_type=nil, binary=false) | |
uploaded_file = ActionController::TestUploadedFile.new( | |
Test::Unit::TestCase.respond_to?(:fixture_path) ? Test::Unit::TestCase.fixture_path + path : path, | |
mime_type, | |
binary | |
) | |
add_attribute attr_name, uploaded_file | |
end | |
end | |
end | |
Factory.send(:include, Factory::FixtureFileUpload) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment