diff --git a/app/models/spree/variant.rb b/app/models/spree/variant.rb index 1d8dda53ff..d91498e310 100644 --- a/app/models/spree/variant.rb +++ b/app/models/spree/variant.rb @@ -69,7 +69,7 @@ module Spree %w(weight volume).include?(variant.product&.variant_unit) } - validates :unit_value, numericality: { greater_than: 0 } + validates :unit_value, numericality: { greater_than: 0 }, allow_blank: true validates :price, numericality: { greater_than_or_equal_to: 0 } validates :unit_description, presence: true, if: ->(variant) { diff --git a/spec/system/admin/bulk_product_update_spec.rb b/spec/system/admin/bulk_product_update_spec.rb index 199c8e218f..a15d7621b4 100644 --- a/spec/system/admin/bulk_product_update_spec.rb +++ b/spec/system/admin/bulk_product_update_spec.rb @@ -307,7 +307,7 @@ describe ' click_button 'Save Changes', match: :first expect(page.find("#status-message")) - .to have_content "Variant unit value can't be blank Variant unit value is not a number" + .to have_content "Variant unit value can't be blank" end it "creating a variant with unit value is: '120g' and 'on_demand' checked" do @@ -323,7 +323,7 @@ describe ' click_button 'Save Changes', match: :first expect(page.find("#status-message")) - .to have_content "Variant unit value can't be blank Variant unit value is not a number" + .to have_content "Variant unit value can't be blank" end end end