Remove unnecessary image file helper

This commit is contained in:
Maikel Linke
2024-01-08 10:58:27 +11:00
parent 6327f46733
commit dd639435f1
4 changed files with 7 additions and 11 deletions

View File

@@ -25,15 +25,17 @@ describe Api::V0::ProductsController, type: :controller do
end
context "as a normal user" do
let(:attachment) { fixture_file_upload("thinking-cat.jpg") }
before do
allow(current_api_user)
.to receive(:has_spree_role?).with("admin").and_return(false)
end
it "gets a single product" do
product.create_image!(attachment: image("thinking-cat.jpg"))
product.create_image!(attachment:)
product.variants.create!(unit_value: "1", unit_description: "thing", price: 1)
product.variants.first.images.create!(attachment: image("thinking-cat.jpg"))
product.variants.first.images.create!(attachment:)
product.set_property("spree", "rocks")
api_get :show, id: product.to_param

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -26,9 +26,5 @@ module OpenFoodNetwork
expect(json_response).to eq("error" => "You are not authorized to perform that action.")
expect(response.status).to eq 401
end
def image(filename)
fixture_file_upload(Rails.root + "spec/support/fixtures" + filename)
end
end
end

View File

@@ -340,6 +340,7 @@ describe '
context "as an enterprise user" do
let!(:tax_category) { create(:tax_category) }
let(:filter) { { producerFilter: 2 } }
let(:image_file_path) { Rails.root.join(file_fixture_path, "thinking-cat.jpg") }
before do
@new_user = create(:user)
@@ -627,14 +628,13 @@ describe '
end
it "upload a new product image including url filters" do
file_path = Rails.root + "spec/support/fixtures/thinking-cat.jpg"
product = create(:simple_product, supplier: @supplier2)
visit spree.admin_product_images_path(product, filter)
page.find('a#new_image_link').click
attach_file('image_attachment', file_path)
attach_file('image_attachment', image_file_path)
click_button "Create"
uri = URI.parse(current_url)
@@ -680,13 +680,11 @@ describe '
viewable_type: 'Spree::Product', alt: "position 1",
attachment: image, position: 1)
file_path = Rails.root + "spec/support/fixtures/thinking-cat.jpg"
visit spree.admin_product_images_path(product, filter)
page.find("a.icon-edit").click
attach_file('image_attachment', file_path)
attach_file('image_attachment', image_file_path)
click_button "Update"
uri = URI.parse(current_url)