fix(champ): champ value formatters should check champ type
This commit is contained in:
parent
d4e6e2effa
commit
a1db089681
3 changed files with 27 additions and 10 deletions
|
@ -185,6 +185,14 @@ describe Champ do
|
|||
|
||||
it { expect(champ.for_export).to eq('Crétinier, Mousserie') }
|
||||
end
|
||||
|
||||
context 'when type_de_champ and champ.type mismatch' do
|
||||
let(:champ_yes_no) { create(:champ_yes_no, value: 'true') }
|
||||
let(:champ_text) { create(:champ_text, value: 'Hello') }
|
||||
|
||||
it { expect(TypeDeChamp.champ_value_for_export(champ_text.type_champ, champ_yes_no)).to eq(nil) }
|
||||
it { expect(TypeDeChamp.champ_value_for_export(champ_yes_no.type_champ, champ_text)).to eq('Non') }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#search_terms' do
|
||||
|
|
|
@ -12,7 +12,7 @@ describe ChampSerializer do
|
|||
end
|
||||
|
||||
context 'when type champ is not piece justificative' do
|
||||
let(:champ) { create(:champ, value: "blah") }
|
||||
let(:champ) { create(:champ_text, value: "blah") }
|
||||
|
||||
it { is_expected.to include(value: "blah") }
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue