use drop_down_options when possible

This commit is contained in:
simon lehericey 2024-09-20 10:56:12 +02:00
parent 77b754a08d
commit 8b5f689a67
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5
14 changed files with 81 additions and 92 deletions

View file

@ -78,13 +78,13 @@ describe Champs::LinkedDropDownListChamp do
end
describe '#mandatory_and_blank' do
let(:value) { "--Primary--\r\nSecondary" }
let(:options) { ["--Primary--", "Secondary"] }
subject { described_class.new }
before { allow(subject).to receive(:type_de_champ).and_return(type_de_champ) }
context 'when the champ is not mandatory' do
let(:type_de_champ) { build(:type_de_champ_linked_drop_down_list, mandatory: false, drop_down_list_value: value) }
let(:type_de_champ) { build(:type_de_champ_linked_drop_down_list, mandatory: false, drop_down_options: options) }
it 'blank is fine' do
is_expected.not_to be_mandatory_blank
@ -92,7 +92,7 @@ describe Champs::LinkedDropDownListChamp do
end
context 'when the champ is mandatory' do
let(:type_de_champ) { build(:type_de_champ_linked_drop_down_list, mandatory: true, drop_down_list_value: value) }
let(:type_de_champ) { build(:type_de_champ_linked_drop_down_list, mandatory: true, drop_down_options: options) }
context 'when there is no value' do
it { is_expected.to be_mandatory_blank }
@ -112,7 +112,7 @@ describe Champs::LinkedDropDownListChamp do
end
context 'when there is nothing to select for the secondary value' do
let(:value) { "--A--\nAbbott\nAbelard\n--B--\n--C--\nCynthia" }
let(:options) { ["--A--", "Abbott", "Abelard", "--B--", "--C--", "Cynthia"] }
before { subject.primary_value = 'B' }
it { is_expected.not_to be_mandatory_blank }

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true
describe Champs::MultipleDropDownListChamp do
let(:type_de_champ) { build(:type_de_champ_multiple_drop_down_list, drop_down_list_value: "val1\r\nval2\r\nval3\r\n[brackets] val4") }
let(:type_de_champ) { build(:type_de_champ_multiple_drop_down_list, drop_down_options: ["val1", "val2", "val3", "[brackets] val4"]) }
let(:value) { nil }
let(:champ) { Champs::MultipleDropDownListChamp.new(value:, dossier: build(:dossier)) }
before do