We can now replace processing in #formatted_value by #to_s calls
This commit is contained in:
parent
f27717ab23
commit
c00aac2f80
6 changed files with 14 additions and 18 deletions
|
@ -14,18 +14,14 @@ module ChampHelper
|
|||
value = champ.value
|
||||
type = champ.type_champ
|
||||
|
||||
if type == TypeDeChamp.type_champs.fetch(:date) && value.present?
|
||||
Date.parse(value).strftime("%d/%m/%Y")
|
||||
if type == TypeDeChamp.type_champs.fetch(:date)
|
||||
champ.to_s
|
||||
elsif type.in? [TypeDeChamp.type_champs.fetch(:checkbox), TypeDeChamp.type_champs.fetch(:engagement)]
|
||||
value == 'on' ? 'Oui' : 'Non'
|
||||
champ.to_s
|
||||
elsif type == TypeDeChamp.type_champs.fetch(:yes_no)
|
||||
if value == 'true'
|
||||
'Oui'
|
||||
elsif value == 'false'
|
||||
'Non'
|
||||
end
|
||||
elsif type == TypeDeChamp.type_champs.fetch(:multiple_drop_down_list) && value.present?
|
||||
JSON.parse(value).join(', ')
|
||||
champ.to_s
|
||||
elsif type == TypeDeChamp.type_champs.fetch(:multiple_drop_down_list)
|
||||
champ.to_s
|
||||
else
|
||||
value
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ class Champs::CheckboxChamp < Champ
|
|||
end
|
||||
|
||||
def to_s
|
||||
value == 'on' ? 'oui' : 'non'
|
||||
value == 'on' ? 'Oui' : 'Non'
|
||||
end
|
||||
|
||||
def for_export
|
||||
|
|
|
@ -16,6 +16,6 @@ class Champs::YesNoChamp < Champs::CheckboxChamp
|
|||
private
|
||||
|
||||
def processed_value
|
||||
value == 'true' ? 'oui' : 'non'
|
||||
value == 'true' ? 'Oui' : 'Non'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -116,7 +116,7 @@ describe Champ do
|
|||
context 'if nil' do
|
||||
let(:value) { nil }
|
||||
|
||||
it { expect(champ.for_export).to eq('non') }
|
||||
it { expect(champ.for_export).to eq('Non') }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -9,13 +9,13 @@ describe Champs::CheckboxChamp do
|
|||
context 'when the value is on' do
|
||||
let(:value) { 'on' }
|
||||
|
||||
it { is_expected.to eq('oui') }
|
||||
it { is_expected.to eq('Oui') }
|
||||
end
|
||||
|
||||
context 'when the value is off' do
|
||||
let(:value) { 'off' }
|
||||
|
||||
it { is_expected.to eq('non') }
|
||||
it { is_expected.to eq('Non') }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,19 +5,19 @@ describe Champs::YesNoChamp do
|
|||
context 'when the value is false' do
|
||||
let(:value) { "false" }
|
||||
|
||||
it { is_expected.to eq("non") }
|
||||
it { is_expected.to eq("Non") }
|
||||
end
|
||||
|
||||
context 'when the value is true' do
|
||||
let(:value) { "true" }
|
||||
|
||||
it { is_expected.to eq("oui") }
|
||||
it { is_expected.to eq("Oui") }
|
||||
end
|
||||
|
||||
context 'when the value is nil' do
|
||||
let(:value) { nil }
|
||||
|
||||
it { is_expected.to eq("non") }
|
||||
it { is_expected.to eq("Non") }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue