I want to test uploading a file in a Rails Rspec request test. I\'m using Paperclip for asset storage.
I\'ve tried:
path = \'path/to/fixture_file\'
para
In rails_helper.rb do
include ActionDispatch::TestProcess
include Rack::Test::Methods
Then you have few options. 1. You can use fixture_file_upload helper
let(:file) { fixture_file_upload('files/image.jpg') }
it 'it should work' do
post some_path, params: { uploads: { file: file } }
end
let(:file) { Rack::Test::UploadedFile.new(Rails.root.join('spec',
'fixtures', 'blank.jpg'), 'image/jpg') }
let(:params) { { attachment: file, variant_ids: ['', product.master.id] } }
let(:action) { post :create, product_id: product.slug, image: params }