Skip to content

Instantly share code, notes, and snippets.

@etaque
Forked from jtrupiano/factory_girl_ext.rb
Created July 11, 2010 06:04
Show Gist options
  • Save etaque/471320 to your computer and use it in GitHub Desktop.
Save etaque/471320 to your computer and use it in GitHub Desktop.
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