Merge pull request #6442 from betagouv/fix_undestructible_secondary_value
Dans une liste déroulante liée, on s'assure que la réinitialisation de la valeur primaire, réinitialise la valeure secondaire
This commit is contained in:
commit
581cd8dd03
2 changed files with 13 additions and 1 deletions
|
@ -41,7 +41,11 @@ class Champs::LinkedDropDownListChamp < Champ
|
||||||
end
|
end
|
||||||
|
|
||||||
def primary_value=(value)
|
def primary_value=(value)
|
||||||
pack_value(value, secondary_value)
|
if value.blank?
|
||||||
|
pack_value("", "")
|
||||||
|
else
|
||||||
|
pack_value(value, secondary_value)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def secondary_value=(value)
|
def secondary_value=(value)
|
||||||
|
|
|
@ -14,6 +14,14 @@ describe Champs::LinkedDropDownListChamp do
|
||||||
it { expect(champ.value).to eq('["tata","tutu"]') }
|
it { expect(champ.value).to eq('["tata","tutu"]') }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#primary_value=' do
|
||||||
|
let!(:champ) { described_class.new(primary_value: 'tata', secondary_value: 'tutu') }
|
||||||
|
|
||||||
|
before { champ.primary_value = '' }
|
||||||
|
|
||||||
|
it { expect(champ.value).to eq('["",""]') }
|
||||||
|
end
|
||||||
|
|
||||||
describe '#to_s' do
|
describe '#to_s' do
|
||||||
let(:champ) { described_class.new(primary_value: primary_value, secondary_value: secondary_value) }
|
let(:champ) { described_class.new(primary_value: primary_value, secondary_value: secondary_value) }
|
||||||
let(:primary_value) { nil }
|
let(:primary_value) { nil }
|
||||||
|
|
Loading…
Add table
Reference in a new issue