Skip to content

armgit / spree

Public Imported from GitHub
0

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.

Added much needed promotion presence validation to PromotionAction/Rule

Damian Legawiecd867c8c11f56
diff --git a/core/app/models/spree/promotion_action.rb b/core/app/models/spree/promotion_action.rb
index cb4a4c5981..34fc2b1d6a 100644
--- a/core/app/models/spree/promotion_action.rb
+++ b/core/app/models/spree/promotion_action.rb
@@ -6,6 +6,8 @@ module Spree
belongs_to :promotion, class_name: 'Spree::Promotion'
+ validates :promotion, presence: true
+
scope :of_type, ->(t) { where(type: t) }
# This method should be overridden in subclass
diff --git a/core/app/models/spree/promotion_rule.rb b/core/app/models/spree/promotion_rule.rb
index 4dac29c322..7ee316528e 100644
--- a/core/app/models/spree/promotion_rule.rb
+++ b/core/app/models/spree/promotion_rule.rb
@@ -7,6 +7,7 @@ module Spree
scope :of_type, ->(t) { where(type: t) }
+ validates :promotion, presence: true
validate :unique_per_promotion, on: :create
def self.for(promotable)