mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Update product duplication
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user