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
Revert "Bulk promo codes improvements" (#12009)
Damian Legawiec31b334e99459
diff --git a/core/app/models/spree/promotion.rb b/core/app/models/spree/promotion.rbindex f93b834bc1..841352e76a 100644--- a/core/app/models/spree/promotion.rb+++ b/core/app/models/spree/promotion.rb@@ -30,7 +30,6 @@ module Spreehas_many :stores, class_name: 'Spree::Store', through: :store_promotionshas_many :promotion_batches, foreign_key: 'template_promotion_id'- has_many :promotions_from_template, through: :promotion_batches, class_name: 'Spree::Promotion', source: :promotionsaccepts_nested_attributes_for :promotion_actions, :promotion_rules@@ -52,10 +51,8 @@ module SpreeSQL}scope :templates, -> { where(template: true) }- scope :for_template_promotion_id, ->(id) { joins(:promotion_batch).where(promotion_batch: { template_promotion_id: id }) }- self.whitelisted_ransackable_attributes = ['path', 'promotion_category_id', 'promotion_batch_id', 'code']- self.whitelisted_ransackable_scopes = ['for_template_promotion_id']+ self.whitelisted_ransackable_attributes = ['path', 'promotion_category_id', 'code']def self.with_coupon_code(coupon_code)where("lower(#{table_name}.code) = ?", coupon_code.strip.downcase).diff --git a/core/app/models/spree/promotion_handler/promotion_batch_duplicator.rb b/core/app/models/spree/promotion_handler/promotion_batch_duplicator.rbindex ad49650037..655632018b 100644--- a/core/app/models/spree/promotion_handler/promotion_batch_duplicator.rb+++ b/core/app/models/spree/promotion_handler/promotion_batch_duplicator.rb@@ -14,7 +14,6 @@ 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/app/services/spree/promotion_batches/generate_code.rb b/core/app/services/spree/promotion_batches/generate_code.rbindex 08161d8dec..f34a464768 100644--- a/core/app/services/spree/promotion_batches/generate_code.rb+++ b/core/app/services/spree/promotion_batches/generate_code.rb@@ -8,7 +8,7 @@ module Spreedef call(random_characters:, prefix: nil, suffix: nil)[prefix,- @random.hex(random_characters).upcase,+ @random.hex(random_characters),suffix].join('')enddiff --git a/core/config/locales/en.yml b/core/config/locales/en.ymlindex 4c17f6aabb..f1ff1ed252 100644--- a/core/config/locales/en.yml+++ b/core/config/locales/en.yml@@ -1743,7 +1743,8 @@ en:taxonomy_tree_error: The requested change has not been accepted and the tree has been returned to its previous state, please try again.taxonomy_tree_instruction: ! '* Right click (or double tap on iOS device) a child in the tree to access the menu for adding, deleting or sorting a child.'taxons: Taxons- template_promotions: Template Promotions+ template_not_found: Template promotion - not found! Assign a template before populating a batch.+ template_promotion_already_assigned: Template promotion has already been assigned!test: Testtest_mailer:test_email:diff --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 1e98e7210d..12aa435e8e 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,7 +18,6 @@ describe Spree::PromotionHandler::PromotionBatchDuplicator docode: 'test1',advertise: true,path: 'test1',- template: true,promotion_category: promo_category,stores: [store, store_2])end@@ -32,7 +31,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', 'template'] }+ let(:excluded_fields) { ['code', 'path', 'id', 'created_at', 'updated_at', 'deleted_at', 'promotion_batch_id', 'usage_limit'] }context "when code is provided" dosubject { described_class.new(promotion, promotion_batch.id, code: provided_code) }@@ -58,10 +57,6 @@ 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' dodiff --git a/core/spec/services/spree/promotion_batches/generate_code_spec.rb b/core/spec/services/spree/promotion_batches/generate_code_spec.rbindex f3848296c3..0f74f8eef3 100644--- a/core/spec/services/spree/promotion_batches/generate_code_spec.rb+++ b/core/spec/services/spree/promotion_batches/generate_code_spec.rb@@ -10,11 +10,11 @@ module Spreelet(:suffix) { nil }before do- allow(random_double).to receive(:hex).with(random_characters).and_return('code')+ allow(random_double).to receive(:hex).with(random_characters).and_return('CODE')endcontext 'when no prefix or suffix is set' do- it 'returns randomly generated code in uppercase' do+ it 'returns randomly generated code' doexpect(subject).to eq('CODE')endend