mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-28 01:53:25 +00:00
DRY uploaded file use in specs
This commit is contained in:
@@ -18,7 +18,7 @@ module Api
|
||||
}
|
||||
|
||||
describe "removing logo" do
|
||||
let(:image) { Rack::Test::UploadedFile.new(black_logo_file, "image/png") }
|
||||
let(:image) { black_logo_file }
|
||||
|
||||
let(:enterprise) { create(:enterprise, owner: enterprise_owner, logo: image) }
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ describe Api::V0::ProductImagesController, type: :controller do
|
||||
render_views
|
||||
|
||||
describe "uploading an image" do
|
||||
let(:image) { Rack::Test::UploadedFile.new(black_logo_file, 'image/png') }
|
||||
let(:image) { black_logo_file }
|
||||
let(:pdf) { Rack::Test::UploadedFile.new(pdf_path, 'application/pdf') }
|
||||
let(:pdf_path) { Rails.public_path.join('Terms-of-service.pdf') }
|
||||
let(:product_without_image) { create(:product) }
|
||||
|
||||
@@ -18,7 +18,7 @@ module Api
|
||||
}
|
||||
|
||||
describe "removing promo image" do
|
||||
let(:image) { Rack::Test::UploadedFile.new(black_logo_file, "image/png") }
|
||||
let(:image) { black_logo_file }
|
||||
|
||||
let(:enterprise) { create(:enterprise, owner: enterprise_owner, promo_image: image) }
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ FactoryBot.define do
|
||||
viewable_id: product.id,
|
||||
viewable_type: 'Spree::Product',
|
||||
alt: "position 1",
|
||||
attachment: Rack::Test::UploadedFile.new(white_logo_path),
|
||||
attachment: white_logo_file,
|
||||
position: 1
|
||||
)
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
module FileHelper
|
||||
def black_logo_file
|
||||
Rack::Test::UploadedFile.new(black_logo_path)
|
||||
Rack::Test::UploadedFile.new(black_logo_path, "image/png")
|
||||
end
|
||||
|
||||
def white_logo_file
|
||||
Rack::Test::UploadedFile.new(white_logo_path)
|
||||
Rack::Test::UploadedFile.new(white_logo_path, "image/png")
|
||||
end
|
||||
|
||||
def black_logo_path
|
||||
|
||||
Reference in New Issue
Block a user