diff --git a/app/models/type_de_champ.rb b/app/models/type_de_champ.rb index 8217a53c3..066093b4d 100644 --- a/app/models/type_de_champ.rb +++ b/app/models/type_de_champ.rb @@ -572,12 +572,8 @@ class TypeDeChamp < ApplicationRecord drop_down_options.presence || [] end - def drop_down_list_disabled_options - drop_down_list_options.filter { |v| (v =~ /^--.*--$/).present? } - end - def drop_down_list_enabled_non_empty_options(other: false) - list_options = (drop_down_list_options - drop_down_list_disabled_options).reject(&:empty?) + list_options = drop_down_list_options.reject(&:empty?) if other && drop_down_other? list_options + [[I18n.t('shared.champs.drop_down_list.other'), Champs::DropDownListChamp::OTHER]] diff --git a/spec/factories/type_de_champ.rb b/spec/factories/type_de_champ.rb index 2352834d9..e6af07b4f 100644 --- a/spec/factories/type_de_champ.rb +++ b/spec/factories/type_de_champ.rb @@ -79,12 +79,9 @@ FactoryBot.define do factory :type_de_champ_drop_down_list do libelle { 'Choix unique' } type_champ { TypeDeChamp.type_champs.fetch(:drop_down_list) } - drop_down_list_value { "val1\r\nval2\r\n--separateur--\r\nval3" } + drop_down_list_value { "val1\r\nval2\r\nval3" } trait :long do - drop_down_list_value { "alpha\r\nbravo\r\n--separateur--\r\ncharly\r\ndelta\r\necho\r\nfox-trot\r\ngolf" } - end - trait :without_selectable_values do - drop_down_list_value { "\r\n--separateur--\r\n--separateur 2--\r\n \r\n" } + drop_down_list_value { "alpha\r\nbravo\r\ncharly\r\ndelta\r\necho\r\nfox-trot\r\ngolf" } end trait :with_other do drop_down_other { true } @@ -92,9 +89,9 @@ FactoryBot.define do end factory :type_de_champ_multiple_drop_down_list do type_champ { TypeDeChamp.type_champs.fetch(:multiple_drop_down_list) } - drop_down_list_value { "val1\r\nval2\r\n--separateur--\r\nval3" } + drop_down_list_value { "val1\r\nval2\r\nval3" } trait :long do - drop_down_list_value { "alpha\r\nbravo\r\n--separateur--\r\ncharly\r\ndelta\r\necho\r\nfox-trot\r\ngolf" } + drop_down_list_value { "alpha\r\nbravo\r\ncharly\r\ndelta\r\necho\r\nfox-trot\r\ngolf" } end end factory :type_de_champ_linked_drop_down_list do diff --git a/spec/models/type_de_champ_spec.rb b/spec/models/type_de_champ_spec.rb index ea9532e6c..48927bb0c 100644 --- a/spec/models/type_de_champ_spec.rb +++ b/spec/models/type_de_champ_spec.rb @@ -218,20 +218,6 @@ describe TypeDeChamp do end end - describe 'disabled_options' do - let(:value) do - <<~EOS - tip - --top-- - --troupt-- - ouaich - EOS - end - let(:type_de_champ) { create(:type_de_champ_drop_down_list, drop_down_list_value: value) } - - it { expect(type_de_champ.drop_down_list_disabled_options).to match(['--top--', '--troupt--']) } - end - describe '#public_only' do let(:procedure) { create(:procedure, :with_type_de_champ, :with_type_de_champ_private) }