Merge pull request #956 from sgmap/fix_export_for_yes_no_champ

Fix export for yes_no champs
This commit is contained in:
Mathieu Magnin 2017-11-21 10:41:42 +01:00 committed by GitHub
commit deb3f02903
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View file

@ -78,7 +78,7 @@ class Champ < ActiveRecord::Base
when 'textarea'
ActionView::Base.full_sanitizer.sanitize(value)
when 'yes_no'
value == 'yes' ? 'oui' : 'non'
value == 'true' ? 'oui' : 'non'
when 'multiple_drop_down_list'
drop_down_list.selected_options_without_decorator(self).join(', ')
else

View file

@ -88,16 +88,22 @@ describe Champ do
let(:type_champ) { 'yes_no' }
context 'if yes' do
let(:value) { 'yes' }
let(:value) { 'true' }
it { expect(champ.for_export).to eq('oui') }
end
context 'if no' do
let(:value) { 'no' }
let(:value) { 'false' }
it { expect(champ.for_export).to eq('non') }
end
context 'if nil' do
let(:value) { nil }
it { expect(champ.for_export).to eq(nil) }
end
end
context 'when type_de_champ is multiple_drop_down_list' do