Migrate product image from master variant to product

This commit is contained in:
Matt-Yorkley
2023-05-22 11:39:38 +01:00
parent d8649fc9fb
commit 7dc1091bc2
37 changed files with 73 additions and 89 deletions

View File

@@ -25,7 +25,7 @@ describe Api::V0::ProductImagesController, type: :controller do
}
expect(response.status).to eq 201
expect(product_without_image.reload.images.first.id).to eq json_response['id']
expect(product_without_image.reload.image.id).to eq json_response['id']
end
it "updates an existing product image" do
@@ -34,7 +34,7 @@ describe Api::V0::ProductImagesController, type: :controller do
}
expect(response.status).to eq 200
expect(product_with_image.reload.images.first.id).to eq json_response['id']
expect(product_with_image.reload.image.id).to eq json_response['id']
end
it "reports errors when saving fails" do
@@ -43,7 +43,7 @@ describe Api::V0::ProductImagesController, type: :controller do
}
expect(response.status).to eq 422
expect(product_without_image.images.count).to eq 0
expect(product_without_image.image).to be_nil
expect(json_response["id"]).to eq nil
expect(json_response["errors"]).to include "Attachment has an invalid content type"
end

View File

@@ -33,7 +33,7 @@ describe Api::V0::ProductsController, type: :controller do
end
it "gets a single product" do
product.master.images.create!(attachment: image("thinking-cat.jpg"))
product.create_image!(attachment: image("thinking-cat.jpg"))
product.variants.create!(unit_value: "1", unit_description: "thing", price: 1)
product.variants.first.images.create!(attachment: image("thinking-cat.jpg"))
product.set_property("spree", "rocks")