From 1449fbbe67e8078e81cdcba5bb152224da8b0ee6 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 18 Mar 2021 14:44:14 +0100 Subject: [PATCH] Fix multiple_drop_down_list mandatory check --- app/models/champ.rb | 2 ++ spec/models/champ_shared_example.rb | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/app/models/champ.rb b/app/models/champ.rb index ef9072e49..864ced9fb 100644 --- a/app/models/champ.rb +++ b/app/models/champ.rb @@ -94,6 +94,8 @@ class Champ < ApplicationRecord case type_de_champ.type_champ when TypeDeChamp.type_champs.fetch(:carte) geo_areas.blank? || value == '[]' + when TypeDeChamp.type_champs.fetch(:multiple_drop_down_list) + value.blank? || value == '[]' else value.blank? end diff --git a/spec/models/champ_shared_example.rb b/spec/models/champ_shared_example.rb index 8ed267e37..1e32f858b 100644 --- a/spec/models/champ_shared_example.rb +++ b/spec/models/champ_shared_example.rb @@ -15,6 +15,12 @@ shared_examples 'champ_spec' do it { expect(champ.mandatory_and_blank?).to be(true) } end + context 'when multiple_drop_down_list mandatory and blank' do + let(:type_de_champ) { build(:type_de_champ_multiple_drop_down_list, mandatory: mandatory) } + let(:value) { '[]' } + it { expect(champ.mandatory_and_blank?).to be(true) } + end + context 'when not blank' do let(:value) { 'yop' } it { expect(champ.mandatory_and_blank?).to be(false) }