Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Clone template promotion without the template flag
Rafal Cymeryscedc27e880de
diff --git a/core/app/models/spree/promotion_handler/promotion_batch_duplicator.rb b/core/app/models/spree/promotion_handler/promotion_batch_duplicator.rbindex 655632018b..ad49650037 100644--- a/core/app/models/spree/promotion_handler/promotion_batch_duplicator.rb+++ b/core/app/models/spree/promotion_handler/promotion_batch_duplicator.rb@@ -14,6 +14,7 @@ module Spreenew_promotion.path = "#{@promotion.path}_#{@code}"new_promotion.code = @codenew_promotion.stores = @promotion.stores+ new_promotion.template = falseActiveRecord::Base.transaction donew_promotion.savediff --git a/core/spec/models/spree/promotion_handler/promotion_batch_duplicator_spec.rb b/core/spec/models/spree/promotion_handler/promotion_batch_duplicator_spec.rbindex 12aa435e8e..1e98e7210d 100644--- a/core/spec/models/spree/promotion_handler/promotion_batch_duplicator_spec.rb+++ b/core/spec/models/spree/promotion_handler/promotion_batch_duplicator_spec.rb@@ -18,6 +18,7 @@ describe Spree::PromotionHandler::PromotionBatchDuplicator docode: 'test1',advertise: true,path: 'test1',+ template: true,promotion_category: promo_category,stores: [store, store_2])end@@ -31,7 +32,7 @@ describe Spree::PromotionHandler::PromotionBatchDuplicator dolet(:promotion_batch) { create(:promotion_batch) }context 'model fields' do- let(:excluded_fields) { ['code', 'path', 'id', 'created_at', 'updated_at', 'deleted_at', 'promotion_batch_id', 'usage_limit'] }+ let(:excluded_fields) { ['code', 'path', 'id', 'created_at', 'updated_at', 'deleted_at', 'promotion_batch_id', 'usage_limit', 'template'] }context "when code is provided" dosubject { described_class.new(promotion, promotion_batch.id, code: provided_code) }@@ -57,6 +58,10 @@ describe Spree::PromotionHandler::PromotionBatchDuplicator doit 'associates the duplicated promotion with a batch' doexpect(new_promotion.promotion_batch_id).to match promotion_batch.idend++ it 'returns a duplicate promotion with template set to false' do+ expect(new_promotion.template?).to be_falsey+ endendcontext 'model associations - rules' do