Merge pull request #7515 from betagouv/fix_other_choice

Corrige l'affichage du choix autre sur les listes des choix
This commit is contained in:
LeSim 2022-07-01 16:39:18 +02:00 committed by GitHub
commit 196ad3081f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View file

@ -56,7 +56,7 @@ class Champs::DropDownListChamp < Champ
end
def drop_down_other?
drop_down_other
drop_down_other == "1" || drop_down_other == true
end
def value=(value)

View file

@ -0,0 +1,24 @@
describe Champs::DropDownListChamp do
describe '#drop_down_other?' do
let(:drop_down) { create(:champ_drop_down_list) }
context 'when drop_down_other is nil' do
it do
drop_down.type_de_champ.drop_down_other = nil
expect(drop_down.drop_down_other?).to be false
drop_down.type_de_champ.drop_down_other = "0"
expect(drop_down.drop_down_other?).to be false
drop_down.type_de_champ.drop_down_other = false
expect(drop_down.drop_down_other?).to be false
drop_down.type_de_champ.drop_down_other = "1"
expect(drop_down.drop_down_other?).to be true
drop_down.type_de_champ.drop_down_other = true
expect(drop_down.drop_down_other?).to be true
end
end
end
end