From 476c7df160980ea25799b5f224afde291049c87e Mon Sep 17 00:00:00 2001 From: mfo Date: Tue, 25 Jun 2024 17:05:33 +0200 Subject: [PATCH] bug(Champs::DecimalNumberChamp.for_export): should be able to cast a number wrapped with a string having leading/trailing spaces --- spec/models/champs/decimal_number_champ_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec/models/champs/decimal_number_champ_spec.rb b/spec/models/champs/decimal_number_champ_spec.rb index 39ead6506..fc5be9d75 100644 --- a/spec/models/champs/decimal_number_champ_spec.rb +++ b/spec/models/champs/decimal_number_champ_spec.rb @@ -51,4 +51,21 @@ describe Champs::DecimalNumberChamp do it { is_expected.to be_truthy } end end + + describe 'for_export' do + let(:champ) { create(:champ_decimal_number, value:) } + subject { champ.for_export } + context 'with nil' do + let(:value) { 0 } + it { is_expected.to be_nil } + end + context 'with simple number' do + let(:value) { "120" } + it { is_expected.to eq(120) } + end + context 'with nuber with space' do + let(:value) { " 120 " } + it { is_expected.to eq(120) } + end + end end