fix(dossier): selecting blank option should not empty selection
This commit is contained in:
parent
f9b7859bf7
commit
ffb332159f
2 changed files with 18 additions and 1 deletions
|
@ -98,7 +98,7 @@ class Champs::MultipleDropDownListChamp < Champ
|
|||
end
|
||||
|
||||
def value=(value)
|
||||
return super(nil) if value.blank?
|
||||
return super(nil) if value.nil?
|
||||
|
||||
values = if value.is_a?(Array)
|
||||
value
|
||||
|
|
|
@ -32,6 +32,23 @@ describe Champs::MultipleDropDownListChamp do
|
|||
|
||||
it { is_expected.not_to be_valid }
|
||||
end
|
||||
|
||||
context 'set value' do
|
||||
it {
|
||||
subject.value = ["val1"]
|
||||
expect(subject.value).to eq("[\"val1\"]")
|
||||
subject.value = 'val2'
|
||||
expect(subject.value).to eq("[\"val1\",\"val2\"]")
|
||||
subject.value = ''
|
||||
expect(subject.value).to eq("[\"val1\",\"val2\"]")
|
||||
subject.value = nil
|
||||
expect(subject.value).to be_nil
|
||||
subject.value = ["val1"]
|
||||
expect(subject.value).to eq("[\"val1\"]")
|
||||
subject.value = []
|
||||
expect(subject.value).to be_nil
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue