From 8cb902821fda2437d8d2d4a8e5eb77d3fe7aa448 Mon Sep 17 00:00:00 2001 From: mfo Date: Tue, 11 Jun 2024 11:40:15 +0200 Subject: [PATCH] bug(draft_types_de_champ_private.condition): condition must be validated with upper_tdcs. considering that types_de_champ_private can have a condition using a types_de_champ_public, we have to include all types_de_champs_public plus only types_de_champs_private.upper_tdcs --- spec/models/procedure_spec.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index 0fa94a425..0b8b3f4ed 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -441,6 +441,33 @@ describe Procedure do end end + context 'when condition on champ private use public champ having a position higher than the champ private' do + include Logic + + let(:types_de_champ_public) do + [ + { type: :decimal_number, stable_id: 1 }, + { type: :decimal_number, stable_id: 2 } + ] + end + + let(:types_de_champ_private) do + [ + { type: :text, condition: ds_eq(champ_value(2), constant(2)), stable_id: 3 } + ] + end + + it 'validate without context' do + procedure.validate + expect(procedure.errors.full_messages_for(:draft_types_de_champ_private)).to be_empty + end + + it 'validate allows condition' do + procedure.validate(:types_de_champ_private_editor) + expect(procedure.errors.full_messages_for(:draft_types_de_champ_private)).to be_empty + end + end + context 'when condition on champ public use private champ' do include Logic let(:types_de_champ_public) { [{ type: :text, libelle: 'condition', condition: ds_eq(champ_value(1), constant(2)), stable_id: 2 }] }