From 85059bfb262d61e83ead3a8b76c75777aeced30b Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Tue, 23 May 2023 15:24:32 +0100 Subject: [PATCH] Remove master variant validation conditionals --- app/models/spree/variant.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/models/spree/variant.rb b/app/models/spree/variant.rb index 38d68b17a0..868987e545 100644 --- a/app/models/spree/variant.rb +++ b/app/models/spree/variant.rb @@ -55,17 +55,16 @@ module Spree validate :check_currency validates :price, numericality: { greater_than_or_equal_to: 0 }, - presence: true, - if: proc { !is_master } + presence: true validates :unit_value, presence: true, if: ->(variant) { - %w(weight volume).include?(variant.product&.variant_unit) && !variant.is_master + %w(weight volume).include?(variant.product&.variant_unit) } - validates :unit_value, numericality: { greater_than: 0 }, if: proc { !is_master } + validates :unit_value, numericality: { greater_than: 0 } validates :unit_description, presence: true, if: ->(variant) { - variant.product&.variant_unit.present? && variant.unit_value.nil? && !variant.is_master + variant.product&.variant_unit.present? && variant.unit_value.nil? } before_validation :set_cost_currency