diff --git a/app/models/spree/product_decorator.rb b/app/models/spree/product_decorator.rb index a7aefcee48..b836cb58e4 100644 --- a/app/models/spree/product_decorator.rb +++ b/app/models/spree/product_decorator.rb @@ -26,7 +26,6 @@ Spree::Product.class_eval do attr_accessible :variant_unit, :variant_unit_scale, :variant_unit_name, :unit_value attr_accessible :inherits_properties, :sku - # validates_presence_of :variants, unless: :new_record?, message: "Product must have at least one variant" validates_presence_of :supplier validates :primary_taxon, presence: { message: I18n.t("validation_msg_product_category_cant_be_blank") } validates :tax_category_id, presence: { message: I18n.t("validation_msg_tax") }, if: "Spree::Config.products_require_tax_category" diff --git a/spec/models/spree/product_spec.rb b/spec/models/spree/product_spec.rb index 25eb0c498f..973e2782ad 100644 --- a/spec/models/spree/product_spec.rb +++ b/spec/models/spree/product_spec.rb @@ -23,13 +23,11 @@ module Spree end it "does not save when master is invalid" do - s = create(:supplier_enterprise) - t = create(:taxon) - product = Product.new supplier_id: s.id, name: "Apples", price: 1, primary_taxon_id: t.id, variant_unit: "weight", variant_unit_scale: 1000, unit_value: 1 - product.on_hand = "10,000" - expect(product.save).to be false + product = build(:product) + product.variant_unit = 'weight' + product.master.unit_value = nil - expect(product.errors[:count_on_hand]).to include "is not a number" + expect(product.save).to eq(false) end it "defaults available_on to now" do