mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-19 04:49:15 +00:00
Only adds standard variant on create
This commit is contained in:
@@ -21,7 +21,7 @@ Spree::Product.class_eval do
|
||||
attr_accessible :supplier_id, :primary_taxon_id, :distributor_ids, :product_distributions_attributes, :group_buy, :group_buy_unit_size
|
||||
attr_accessible :variant_unit, :variant_unit_scale, :variant_unit_name, :unit_value, :unit_description, :notes, :images_attributes, :display_as
|
||||
|
||||
before_validation :ensure_standard_variant
|
||||
before_validation :ensure_standard_variant, if: :new_record?
|
||||
|
||||
validates_presence_of :supplier
|
||||
validates :primary_taxon, presence: { message: "^Product Category can't be blank" }
|
||||
|
||||
@@ -106,6 +106,11 @@ module Spree
|
||||
standard_variant = product.variants(:reload).first
|
||||
expect(standard_variant.price).to eq product.master.price
|
||||
end
|
||||
|
||||
it "only duplicates master variant on initial save" do
|
||||
product.save!
|
||||
expect(product.variants(:reload).length).to eq 1
|
||||
end
|
||||
end
|
||||
|
||||
context "when the unit is items" do
|
||||
|
||||
Reference in New Issue
Block a user