Update product duplication

This commit is contained in:
Matt-Yorkley
2023-08-07 15:31:53 +01:00
parent 820f9530b2
commit e4a49f5d02
2 changed files with 1 additions and 22 deletions

View File

@@ -20,7 +20,6 @@ module Spree
def duplicate_product
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

View File

@@ -9,10 +9,6 @@ module Spree
let(:product) { create(:product) }
context '#duplicate' do
before do
allow(product).to receive_messages taxons: [create(:taxon)]
end
it 'duplicates product' do
clone = product.duplicate
expect(clone.name).to eq 'COPY OF ' + product.name
@@ -170,7 +166,7 @@ module Spree
end
it "requires a primary taxon" do
expect(build(:simple_product, taxons: [], primary_taxon: nil)).not_to be_valid
expect(build(:simple_product, primary_taxon: nil)).not_to be_valid
end
it "requires a unit value" do
@@ -316,22 +312,6 @@ module Spree
end
end
it "adds the primary taxon to the product's taxon list" do
taxon = create(:taxon)
product = create(:product, primary_taxon: taxon)
expect(product.taxons).to include(taxon)
end
it "removes the previous primary taxon from the taxon list" do
original_taxon = create(:taxon)
product = create(:product, primary_taxon: original_taxon)
product.primary_taxon = create(:taxon)
product.save!
expect(product.taxons).not_to include(original_taxon)
end
it "updates units when saved change to variant unit" do
product.variant_unit = 'items'
product.variant_unit_scale = nil