Champ: export multiple_drop_down_list as a [].join(', ')

This commit is contained in:
Simon Lehericey 2017-10-27 10:01:53 +02:00
parent b658f8c8dc
commit f4a8ff31b9
2 changed files with 11 additions and 0 deletions

View file

@ -77,6 +77,8 @@ class Champ < ActiveRecord::Base
ActionView::Base.full_sanitizer.sanitize(value)
when 'yes_no'
value == 'yes' ? 'oui' : 'non'
when 'multiple_drop_down_list'
drop_down_list.selected_options_without_decorator(self).join(', ')
else
value
end

View file

@ -99,5 +99,14 @@ describe Champ do
it { expect(champ.for_export).to eq('non') }
end
end
context 'when type_de_champ is multiple_drop_down_list' do
let(:type_champ) { 'multiple_drop_down_list' }
let(:value) { '["Crétinier", "Mousserie"]' }
before { type_de_champ.drop_down_list = create(:drop_down_list) }
it { expect(champ.for_export).to eq('Crétinier, Mousserie') }
end
end
end