multiple_select: fix decorateur interference
This commit is contained in:
parent
b3624256cd
commit
ebd2051337
2 changed files with 3 additions and 4 deletions
|
@ -11,7 +11,7 @@ class DropDownList < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def selected_options(champ)
|
||||
champ.value.blank? ? [] : multiple ? JSON.parse(champ.value) : [champ.value]
|
||||
champ.object.value.blank? ? [] : multiple ? JSON.parse(champ.object.value) : [champ.object.value]
|
||||
end
|
||||
|
||||
def multiple
|
||||
|
|
|
@ -41,7 +41,6 @@ ouaich" }
|
|||
end
|
||||
|
||||
describe 'selected_options' do
|
||||
|
||||
let(:dropdownlist) do
|
||||
create(:drop_down_list, type_de_champ: type_de_champ)
|
||||
end
|
||||
|
@ -49,14 +48,14 @@ ouaich" }
|
|||
context 'when multiple' do
|
||||
let(:type_de_champ) { TypeDeChamp.new(type_champ: 'multiple_drop_down_list') }
|
||||
|
||||
let(:champ) { Champ.new(value: '["1","2"]') }
|
||||
let(:champ) { Champ.new(value: '["1","2"]').decorate }
|
||||
it { expect(dropdownlist.selected_options(champ)).to match(['1', '2']) }
|
||||
end
|
||||
|
||||
context 'when simple' do
|
||||
let(:type_de_champ) { TypeDeChamp.new(type_champ: 'drop_down_list') }
|
||||
|
||||
let(:champ) { Champ.new(value: '1') }
|
||||
let(:champ) { Champ.new(value: '1').decorate }
|
||||
it { expect(dropdownlist.selected_options(champ)).to match(['1']) }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue