How can i create fixtures file for test paperclip upload? I search fews result in google but always use with FactoryGirl. I tried but not work:
img:
image: <%= fixture_file_upload(Rails.root.join('test/fixtures/test_img.jpg'), 'image/jpeg') %>
You cannot do that with fixtures. Fixtures are adding attribute values directly to the database, skipping the active record layer. Paperclip is a plugin for ActiveRecord, that processing and storing photos.
Saving the real image can be done only passing arguments directly to the new record.
What you can do is to put attributes into the fixture so the paperclip will work as it should, just without real file.
photo_file_name: temp_file.jpg
photo_content_type: image/jpeg
photo_file_size: 223312
photo_updated_at: 2015-02-29 10:30:19 Z
When you want to make everything correct, better to use FactoryGirl
.
fixture_file_upload
is only used for action controller.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With