mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-05 02:41:33 +00:00
When product unit changed, remove option types from master as well as other variants
This commit is contained in:
@@ -151,7 +151,7 @@ Spree::Product.class_eval do
|
||||
if variant_unit_changed?
|
||||
option_types.delete self.class.all_variant_unit_option_types
|
||||
option_types << variant_unit_option_type if variant_unit.present?
|
||||
variants.each { |v| v.delete_unit_option_values }
|
||||
variants_including_master.each { |v| v.delete_unit_option_values }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -429,6 +429,16 @@ module Spree
|
||||
p.update_attributes!(variant_unit: 'volume', variant_unit_scale: 0.001)
|
||||
}.to change(v.option_values(true), :count).by(-1)
|
||||
end
|
||||
|
||||
it "removes the related option values from its master variant" do
|
||||
ot = Spree::OptionType.find_by_name 'unit_weight'
|
||||
p.master.update_attributes!(unit_value: 1)
|
||||
p.reload
|
||||
|
||||
expect {
|
||||
p.update_attributes!(variant_unit: 'volume', variant_unit_scale: 0.001)
|
||||
}.to change(p.master.option_values(true), :count).by(-1)
|
||||
end
|
||||
end
|
||||
|
||||
describe "returning the variant unit option type" do
|
||||
|
||||
Reference in New Issue
Block a user