From 41440af533fa3e764523d49eafb7348989305b89 Mon Sep 17 00:00:00 2001 From: Mohamed ABDELLANI Date: Mon, 24 Oct 2022 09:50:05 +0100 Subject: [PATCH] test if product's variant is duplicated properly --- spec/lib/spree/core/product_duplicator_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec/lib/spree/core/product_duplicator_spec.rb b/spec/lib/spree/core/product_duplicator_spec.rb index 0c1c3023a6..58047b1224 100644 --- a/spec/lib/spree/core/product_duplicator_spec.rb +++ b/spec/lib/spree/core/product_duplicator_spec.rb @@ -74,7 +74,9 @@ describe Spree::Core::ProductDuplicator do before do expect(product).to receive(:dup).and_return(new_product) expect(master_variant).to receive(:dup).and_return(new_master_variant) + expect(variant).to receive(:dup).and_return(new_variant) expect(image).to receive(:dup).and_return(new_image) + expect(image_variant).to receive(:dup).and_return(new_image_variant) expect(property).to receive(:dup).and_return(new_property) end @@ -88,6 +90,7 @@ describe Spree::Core::ProductDuplicator do expect(new_product).to receive(:deleted_at=).with(nil) expect(new_product).to receive(:master=).with(new_master_variant) expect(new_product).to receive(:option_types=).with([]) + expect(new_product).to receive(:variants=).with([new_variant]) expect(new_master_variant).to receive(:sku=).with("") expect(new_master_variant).to receive(:deleted_at=).with(nil) @@ -95,9 +98,18 @@ describe Spree::Core::ProductDuplicator do expect(new_master_variant).to receive(:price=).with(master_variant.price) expect(new_master_variant).to receive(:currency=).with(master_variant.currency) + expect(new_variant).to receive(:sku=).with("") + expect(new_variant).to receive(:deleted_at=).with(nil) + expect(new_variant).to receive(:images=).with([new_image_variant]) + expect(new_variant).to receive(:price=).with(variant.price) + expect(new_variant).to receive(:currency=).with(variant.currency) + expect(image).to receive(:attachment_blob) expect(new_image).to receive_message_chain(:attachment, :attach) + expect(image_variant).to receive(:attachment_blob) + expect(new_image_variant).to receive_message_chain(:attachment, :attach) + expect(new_property).to receive(:created_at=).with(nil) expect(new_property).to receive(:updated_at=).with(nil)