Champ: export yes_no champ with oui non

This commit is contained in:
Simon Lehericey 2017-10-26 17:45:35 +02:00
parent 338911d1a8
commit b658f8c8dc
2 changed files with 17 additions and 0 deletions

View file

@ -75,6 +75,8 @@ class Champ < ActiveRecord::Base
case type_champ
when 'textarea'
ActionView::Base.full_sanitizer.sanitize(value)
when 'yes_no'
value == 'yes' ? 'oui' : 'non'
else
value
end

View file

@ -84,5 +84,20 @@ describe Champ do
it { expect(champ.for_export).to eq('gras') }
end
context 'when type_de_champ is yes_no' do
let(:type_champ) { 'yes_no' }
context 'if yes' do
let(:value) { 'yes' }
it { expect(champ.for_export).to eq('oui') }
end
context 'if no' do
let(:value) { 'no' }
it { expect(champ.for_export).to eq('non') }
end
end
end
end