mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Merge pull request #3152 from coopdevs/fix-product-spec
[Spree Upgrade] Fix product spec
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user