Merge pull request #8872 from tchak/fix-champ-multiselect
fix(dossier): selecting blank option should not empty selection
This commit is contained in:
commit
79fee39888
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