diff --git a/app/models/variant_override.rb b/app/models/variant_override.rb index 9fd26b1ed4..66a93e473b 100644 --- a/app/models/variant_override.rb +++ b/app/models/variant_override.rb @@ -15,6 +15,8 @@ class VariantOverride < ApplicationRecord validates :variant, presence: true # Default stock can be nil, indicating stock should not be reset or zero, meaning reset to zero. Need to ensure this can be set by the user. validates :default_stock, numericality: { greater_than_or_equal_to: 0 }, allow_nil: true + validates :price, numericality: { greater_than_or_equal_to: 0 }, allow_nil: true + validates :count_on_hand, numericality: { greater_than_or_equal_to: 0 }, allow_nil: true default_scope { where(permission_revoked_at: nil) } diff --git a/spec/models/spree/line_item_spec.rb b/spec/models/spree/line_item_spec.rb index 848b5a8271..261a2f635d 100644 --- a/spec/models/spree/line_item_spec.rb +++ b/spec/models/spree/line_item_spec.rb @@ -265,16 +265,6 @@ module Spree li.cap_quantity_at_stock! expect(li.quantity).to eq 2 end - - context "when count on hand is negative" do - before { vo.update(count_on_hand: -3) } - - it "caps at zero" do - v.__send__(:stock_item).update_column(:count_on_hand, -2) - li.cap_quantity_at_stock! - expect(li.reload.quantity).to eq 0 - end - end end end