From f9accde060e8c93a999bfe16cda895f51b9ec24e Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Sat, 30 Nov 2024 15:47:27 +0100 Subject: [PATCH] Legacy Promotions: Remove unneeded decorator This is an artifact of the piece-by-piece extraction process I believe. Since is now done, we can remove this decorator. (cherry picked from commit 9a74fda94e3b86d31b01b0dd7f72406899888c1a) --- .../spree_promotion_code_batch_decorator.rb | 16 ---------------- .../app/models/spree/promotion_code_batch.rb | 9 +++++++++ 2 files changed, 9 insertions(+), 16 deletions(-) delete mode 100644 legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree_promotion_code_batch_decorator.rb diff --git a/legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree_promotion_code_batch_decorator.rb b/legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree_promotion_code_batch_decorator.rb deleted file mode 100644 index fdb8c85454b..00000000000 --- a/legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree_promotion_code_batch_decorator.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -module SolidusLegacyPromotions - module SpreePromotionCodeBatchDecorator - def process - if state == "pending" - update!(state: "processing") - Spree::PromotionCodeBatchJob.perform_later(self) - else - raise Spree::PromotionCodeBatch::CantProcessStartedBatch.new("Batch #{id} already started") - end - end - - Spree::PromotionCodeBatch.prepend(self) - end -end diff --git a/legacy_promotions/app/models/spree/promotion_code_batch.rb b/legacy_promotions/app/models/spree/promotion_code_batch.rb index 66cbcc50d6a..85a17be14be 100644 --- a/legacy_promotions/app/models/spree/promotion_code_batch.rb +++ b/legacy_promotions/app/models/spree/promotion_code_batch.rb @@ -14,5 +14,14 @@ class CantProcessStartedBatch < StandardError def finished? state == "completed" end + + def process + if state == "pending" + update!(state: "processing") + PromotionCodeBatchJob.perform_later(self) + else + raise CantProcessStartedBatch.new("Batch #{id} already started") + end + end end end