Merge pull request #2362 from betagouv/fix_2358_checkbox

[fix #2358] Checkbox: serialize in attestation by oui or non
This commit is contained in:
LeSim 2018-08-10 17:11:03 +02:00 committed by GitHub
commit 9fed32456c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 0 deletions

View file

@ -4,4 +4,8 @@ class Champs::CheckboxChamp < Champ
[ libelle ]
end
end
def to_s
value == 'on' ? 'oui' : 'non'
end
end

View file

@ -0,0 +1,21 @@
require 'spec_helper'
describe Champs::CheckboxChamp do
let(:checkbox) { Champs::CheckboxChamp.new(value: value) }
describe '#to_s' do
subject { checkbox.to_s }
context 'when the value is on' do
let(:value) { 'on' }
it { is_expected.to eq('oui') }
end
context 'when the value is off' do
let(:value) { 'off' }
it { is_expected.to eq('non') }
end
end
end