bug(Champs::DecimalNumberChamp.for_export): should be able to cast a number wrapped with a string having leading/trailing spaces

This commit is contained in:
mfo 2024-06-25 17:05:33 +02:00
parent 828c539469
commit 476c7df160
No known key found for this signature in database
GPG key ID: 7CE3E1F5B794A8EC

View file

@ -51,4 +51,21 @@ describe Champs::DecimalNumberChamp do
it { is_expected.to be_truthy } it { is_expected.to be_truthy }
end end
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 end