I am having difficulties with testing image download.
def download_img
@image = Photo.find params[:id] unless params[:id].nil?
@c = Cat.find params[:cat_id] unless params[:cat_id].nil?
@foo = @image.foo unless @image.nil?
send_file(Paperclip.io_adapters.for(@image.file).path, type: "jpeg", :disposition => "attachment", :filename => @image.name)
end
My RSpec test (controller):
describe 'download_img' do
before do
get :download_img, { id: image.id }
end
it 'retrieves image by id' do
img = Photo.find image.id
expect(img).not_to be_nil
end
it 'downloads image' do
page.response_headers["Content-Type"].should == "application/jpg"
page.response_headers["Content-Disposition"].should == "attachment; filename=\"image.name.jpg\""
end
end
When I run rspec test for both tests I get an error: "No such file or directory @ rb_sysopen - /home/public/system/photos/files/000/000/001/foo/IMG123.JPG"
Thank you.