diff --git a/app/models/types_de_champ/drop_down_list_type_de_champ.rb b/app/models/types_de_champ/drop_down_list_type_de_champ.rb index eee0c03b8..4b9058397 100644 --- a/app/models/types_de_champ/drop_down_list_type_de_champ.rb +++ b/app/models/types_de_champ/drop_down_list_type_de_champ.rb @@ -1,17 +1,4 @@ # frozen_string_literal: true class TypesDeChamp::DropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBase - def champ_blank?(champ) - super || !champ_value_in_options?(champ) - end - - private - - def champ_value_in_options?(champ) - champ_with_other_value?(champ) || drop_down_options.include?(champ.value) - end - - def champ_with_other_value?(champ) - drop_down_other? && champ.value_json&.fetch('other', false) - end end diff --git a/app/models/types_de_champ/multiple_drop_down_list_type_de_champ.rb b/app/models/types_de_champ/multiple_drop_down_list_type_de_champ.rb index bbca8ee52..1be2be9d5 100644 --- a/app/models/types_de_champ/multiple_drop_down_list_type_de_champ.rb +++ b/app/models/types_de_champ/multiple_drop_down_list_type_de_champ.rb @@ -24,7 +24,7 @@ class TypesDeChamp::MultipleDropDownListTypeDeChamp < TypesDeChamp::TypeDeChampB [champ.value] else JSON.parse(champ.value) - end.filter { drop_down_options.include?(_1) } + end rescue JSON::ParserError [] end diff --git a/spec/models/concerns/dossier_rebase_concern_spec.rb b/spec/models/concerns/dossier_rebase_concern_spec.rb index 851080b30..1f54fa997 100644 --- a/spec/models/concerns/dossier_rebase_concern_spec.rb +++ b/spec/models/concerns/dossier_rebase_concern_spec.rb @@ -449,7 +449,7 @@ describe DossierRebaseConcern do tdc_to_update.update(drop_down_options: ["option", "updated"]) end - it { expect { subject }.to change { dossier.project_champs_public.first.to_s }.from('v1').to('') } + it { expect { subject }.not_to change { dossier.project_champs_public.first.to_s } } end context 'when a dropdown unused option is removed' do @@ -495,7 +495,7 @@ describe DossierRebaseConcern do tdc_to_update.update(drop_down_options: ["option", "updated"]) end - it { expect { subject }.to change { dossier.project_champs_public.first.to_s }.from('v1, option').to('option') } + it { expect { subject }.not_to change { dossier.project_champs_public.first.to_s } } end context 'when a dropdown unused option is removed' do