mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-18 00:17:25 +00:00
Replace api controller test helpers with easier existing alternatives
This commit is contained in:
@@ -14,8 +14,7 @@ module Api
|
||||
let(:image) { Rack::Test::UploadedFile.new(image_path, 'image/png') }
|
||||
let!(:product_without_image) { create(:product) }
|
||||
let!(:product_with_image) { create(:product_with_image) }
|
||||
|
||||
sign_in_as_admin!
|
||||
let(:current_api_user) { create(:admin_user) }
|
||||
|
||||
it "saves a new image when none is present" do
|
||||
xhr :post, :update_product_image, product_id: product_without_image.id, file: image, use_route: :product_images
|
||||
|
||||
@@ -84,7 +84,7 @@ describe Api::VariantsController, type: :controller do
|
||||
end
|
||||
|
||||
context "as an enterprise user" do
|
||||
sign_in_as_enterprise_user! [:supplier]
|
||||
let(:current_api_user) { create(:user, enterprises: [supplier]) }
|
||||
let(:supplier_other) { create(:supplier_enterprise) }
|
||||
let(:product) { create(:product, supplier: supplier) }
|
||||
let(:variant) { product.master }
|
||||
@@ -109,7 +109,7 @@ describe Api::VariantsController, type: :controller do
|
||||
end
|
||||
|
||||
context "as an administrator" do
|
||||
sign_in_as_admin!
|
||||
let(:current_api_user) { create(:admin_user) }
|
||||
|
||||
let(:product) { create(:product) }
|
||||
let(:variant) { product.master }
|
||||
|
||||
Reference in New Issue
Block a user