Skip to content

Instantly share code, notes, and snippets.

@jtrupiano
Created February 26, 2010 21:39
Show Gist options
  • Save jtrupiano/316188 to your computer and use it in GitHub Desktop.
Save jtrupiano/316188 to your computer and use it in GitHub Desktop.
Add fixture_file_upload to factory_girl
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