From 7bfafb6fc203b77d076f33e5044a75ebae3cb6e0 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 21 Nov 2017 10:28:21 +0100 Subject: [PATCH] Fix export for yes_no champs --- app/models/champ.rb | 2 +- spec/models/champ_spec.rb | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/models/champ.rb b/app/models/champ.rb index ee0ee446f..872a6a996 100644 --- a/app/models/champ.rb +++ b/app/models/champ.rb @@ -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 diff --git a/spec/models/champ_spec.rb b/spec/models/champ_spec.rb index 40435750a..1db3481da 100644 --- a/spec/models/champ_spec.rb +++ b/spec/models/champ_spec.rb @@ -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