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:
commit
196ad3081f
2 changed files with 25 additions and 1 deletions
|
@ -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)
|
||||
|
|
24
spec/models/champs/drop_down_list_champ_spec.rb
Normal file
24
spec/models/champs/drop_down_list_champ_spec.rb
Normal 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
|
Loading…
Reference in a new issue