Merge pull request #2957 from betagouv/fix_2956_yes_no_to_s
[fix #2956] YesNo: fixing to_s
This commit is contained in:
commit
c11eb80e11
2 changed files with 27 additions and 0 deletions
|
@ -5,6 +5,10 @@ class Champs::YesNoChamp < Champs::CheckboxChamp
|
|||
end
|
||||
end
|
||||
|
||||
def to_s
|
||||
value_for_export
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def value_for_export
|
||||
|
|
23
spec/models/champs/yes_no_champ_spec.rb
Normal file
23
spec/models/champs/yes_no_champ_spec.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
describe Champs::YesNoChamp do
|
||||
describe '#to_s' do
|
||||
subject { Champs::YesNoChamp.new(value: value).to_s }
|
||||
|
||||
context 'when the value is false' do
|
||||
let(:value) { "false" }
|
||||
|
||||
it { is_expected.to eq("non") }
|
||||
end
|
||||
|
||||
context 'when the value is true' do
|
||||
let(:value) { "true" }
|
||||
|
||||
it { is_expected.to eq("oui") }
|
||||
end
|
||||
|
||||
context 'when the value is nil' do
|
||||
let(:value) { nil }
|
||||
|
||||
it { is_expected.to eq("non") }
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue