Merge pull request #2362 from betagouv/fix_2358_checkbox
[fix #2358] Checkbox: serialize in attestation by oui or non
This commit is contained in:
commit
9fed32456c
2 changed files with 25 additions and 0 deletions
|
@ -4,4 +4,8 @@ class Champs::CheckboxChamp < Champ
|
||||||
[ libelle ]
|
[ libelle ]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
value == 'on' ? 'oui' : 'non'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
21
spec/models/champs/checkbox_champ_spec.rb
Normal file
21
spec/models/champs/checkbox_champ_spec.rb
Normal 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
|
Loading…
Add table
Reference in a new issue