Skip to content

Instantly share code, notes, and snippets.

@sr3d
Created June 16, 2010 22:42
Show Gist options
  • Save sr3d/441392 to your computer and use it in GitHub Desktop.
Save sr3d/441392 to your computer and use it in GitHub Desktop.
Paperclip - Factory_Girl for Rails 3 beta 4
Factory.define :contacts_short_csv, :class => 'CsvFile' do |f|
include ActionDispatch::TestProcess
f.csv { fixture_file_upload( 'files/contacts_short.csv.upload', 'text/csv') }
f.account_id { 1 }
end
My model is
class CsvFile < ActiveRecord::Base
include Paperclip
has_attached_file :csv
end
The CSV file is actually under test/fixtures/files/ and since they are not real fixture data, but actual CSV data for testing the data import process, I had to rename them as .csv.upload otherwise Rails's test will try to populate the test databases with them (and fail miserably)
I'm using Rails 3b4, with latest paperclip 61f74...eed69-master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment