diff --git a/app/services/weights_and_measures.rb b/app/services/weights_and_measures.rb index eaf66b3ec4..c2bc8c313c 100644 --- a/app/services/weights_and_measures.rb +++ b/app/services/weights_and_measures.rb @@ -14,7 +14,7 @@ class WeightsAndMeasures end def system - scales = scales_for_variant_unit + return "custom" unless scales = scales_for_variant_unit return "custom" unless product_scale = @variant.product.variant_unit_scale scales[product_scale.to_f]['system'] diff --git a/spec/services/weights_and_measures_spec.rb b/spec/services/weights_and_measures_spec.rb index 435ac0f5e4..c6f98e6e5a 100644 --- a/spec/services/weights_and_measures_spec.rb +++ b/spec/services/weights_and_measures_spec.rb @@ -37,11 +37,17 @@ describe WeightsAndMeasures do end context "items" do - it "when scale is for items" do + it "when variant unit is items" do allow(product).to receive(:variant_unit) { "items" } allow(product).to receive(:variant_unit_scale) { nil } expect(subject.system).to eq("custom") end + + it "when variant unit is items, even if the scale is present" do + allow(product).to receive(:variant_unit) { "items" } + allow(product).to receive(:variant_unit_scale) { 1.0 } + expect(subject.system).to eq("custom") + end end end