Blank out product SKU when cloning a product

This was effectively being done before for the product's sku (stored on the master variant) via the #duplicate_variant method, but now it needs to be done explicitly on the product in #duplicate_product

(cherry picked from commit 0f253bb2a0)
This commit is contained in:
Matt-Yorkley
2023-06-09 11:43:43 +01:00
committed by David Cook
parent b1de64bf3e
commit 05d9646f3e
3 changed files with 3 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ module Spree
product.dup.tap do |new_product|
new_product.name = "COPY OF #{product.name}"
new_product.taxons = product.taxons
new_product.sku = ""
new_product.created_at = nil
new_product.deleted_at = nil
new_product.updated_at = nil

View File

@@ -69,6 +69,7 @@ describe Spree::Core::ProductDuplicator do
duplicator = Spree::Core::ProductDuplicator.new(product)
expect(new_product).to receive(:name=).with("COPY OF foo")
expect(new_product).to receive(:taxons=).with([])
expect(new_product).to receive(:sku=).with("")
expect(new_product).to receive(:product_properties=).with([new_property])
expect(new_product).to receive(:created_at=).with(nil)
expect(new_product).to receive(:unit_value=).with(true)

View File

@@ -16,6 +16,7 @@ module Spree
it 'duplicates product' do
clone = product.duplicate
expect(clone.name).to eq 'COPY OF ' + product.name
expect(clone.sku).to eq ""
expect(clone.image).to eq product.image
end
end