From ab542cfdb2fa096a1e399a63f5e9b3c29e7217a5 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Wed, 28 Nov 2018 17:39:51 +0100 Subject: [PATCH 1/2] Remove commented out code --- app/models/spree/product_decorator.rb | 1 - 1 file changed, 1 deletion(-) 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" From 7834b1d3f3c2382456ac9c007d4642713da75909 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Wed, 28 Nov 2018 17:39:59 +0100 Subject: [PATCH 2/2] Fix test case for invalid product master --- spec/models/spree/product_spec.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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