Displaying 1 result from an estimated 1 matches for "import_spec".
2009 Nov 10
4
Model spec for file upload with paperclip and fastercsv
...as really the way to
go:
////////import.rb/////////////////
class Import < ActiveRecord::Base
has_attached_file :csv
validates_attachment_presence :csv
after_save :process_csv
private
def process_csv
FasterCSV.foreach( csv.path) do |row|
#TODO
end
end
end
/////////import_spec.rb/////////////////
require ''spec_helper''
describe Import do
it "should should succeed creating a valid Import from the factory" do
import = Factory.build(:import)
import.csv.stub!(:url).and_return("#{RAILS_ROOT}/spec/csv/3_products.csv")
impor...