mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-02 02:11:33 +00:00
Add test for enterprise logo and promo image uploading
- Add a fixture image to do the upload thanks to `fixture_file_upload` - Check the response status, the content type and the response body for both logo image and promo image
This commit is contained in:
@@ -75,15 +75,24 @@ describe Api::V0::EnterprisesController, type: :controller do
|
||||
end
|
||||
|
||||
describe "submitting a valid image" do
|
||||
let!(:logo) { fixture_file_upload("files/logo.png", "image/png") }
|
||||
before do
|
||||
allow(Enterprise)
|
||||
.to receive(:find_by).with({ permalink: enterprise.id.to_s }) { enterprise }
|
||||
allow(enterprise).to receive(:update).and_return(true)
|
||||
end
|
||||
|
||||
it "I can update enterprise image" do
|
||||
api_post :update_image, logo: 'a logo', id: enterprise.id
|
||||
it "I can update enterprise logo image" do
|
||||
api_post :update_image, logo: logo, id: enterprise.id
|
||||
expect(response.status).to eq 200
|
||||
expect(response.content_type).to eq "text/html"
|
||||
expect(response.body).to match %r{/images/enterprises/logos/\d*/medium/logo\.png\?\d*}
|
||||
end
|
||||
|
||||
it "I can update enterprise promo image" do
|
||||
api_post :update_image, promo: logo, id: enterprise.id
|
||||
expect(response.status).to eq 200
|
||||
expect(response.content_type).to eq "text/html"
|
||||
expect(response.body).to match %r{/images/enterprises/promo_images/\d*/medium/logo\.jpg\?\d*}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
BIN
spec/fixtures/files/logo.png
vendored
Normal file
BIN
spec/fixtures/files/logo.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.1 KiB |
Reference in New Issue
Block a user