From dec6d2189fd1ec443c9a038947613b4a308c8348 Mon Sep 17 00:00:00 2001 From: Andy Brett Date: Sun, 21 Feb 2021 22:26:36 -0800 Subject: [PATCH] add unit test for unit_value --- spec/models/spree/variant_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/models/spree/variant_spec.rb b/spec/models/spree/variant_spec.rb index cfd0d41d8b..a2c2b47f22 100644 --- a/spec/models/spree/variant_spec.rb +++ b/spec/models/spree/variant_spec.rb @@ -799,5 +799,13 @@ module Spree expect(variant.unit_value).to eq 1 end end + + context "trying to set an invalid unit_value" do + it "does not allow NaN" do + variant.update(unit_value: Float::NAN) + + expect(variant.reload.unit_value).to eq(1.0) + end + end end end