remove text from managed_type_de_champ
This commit is contained in:
parent
c631c5cd82
commit
d8454d9d47
5 changed files with 10 additions and 25 deletions
|
@ -27,8 +27,6 @@ module Logic
|
|||
in [:number, EmptyOperator]
|
||||
operator_class = Eq
|
||||
in [:number, _]
|
||||
in [:string, _]
|
||||
operator_class = Eq
|
||||
end
|
||||
|
||||
if !compatible_type?(left, right)
|
||||
|
@ -41,8 +39,6 @@ module Logic
|
|||
Constant.new(left.options.first)
|
||||
when :number
|
||||
Constant.new(0)
|
||||
when :string
|
||||
Constant.new('')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -4,14 +4,12 @@ class Logic::ChampValue < Logic::Term
|
|||
:checkbox,
|
||||
:integer_number,
|
||||
:decimal_number,
|
||||
:drop_down_list,
|
||||
:text
|
||||
:drop_down_list
|
||||
)
|
||||
|
||||
CHAMP_VALUE_TYPE = {
|
||||
boolean: :boolean,
|
||||
number: :number,
|
||||
string: :string,
|
||||
enum: :enum,
|
||||
empty: :empty,
|
||||
unmanaged: :unmanaged
|
||||
|
@ -30,7 +28,7 @@ class Logic::ChampValue < Logic::Term
|
|||
champ(champs).true?
|
||||
when MANAGED_TYPE_DE_CHAMP.fetch(:integer_number), MANAGED_TYPE_DE_CHAMP.fetch(:decimal_number)
|
||||
champ(champs).for_api
|
||||
when MANAGED_TYPE_DE_CHAMP.fetch(:drop_down_list), MANAGED_TYPE_DE_CHAMP.fetch(:text)
|
||||
when MANAGED_TYPE_DE_CHAMP.fetch(:drop_down_list)
|
||||
champ(champs).value
|
||||
end
|
||||
end
|
||||
|
@ -44,8 +42,6 @@ class Logic::ChampValue < Logic::Term
|
|||
CHAMP_VALUE_TYPE.fetch(:boolean)
|
||||
when MANAGED_TYPE_DE_CHAMP.fetch(:integer_number), MANAGED_TYPE_DE_CHAMP.fetch(:decimal_number)
|
||||
CHAMP_VALUE_TYPE.fetch(:number)
|
||||
when MANAGED_TYPE_DE_CHAMP.fetch(:text)
|
||||
CHAMP_VALUE_TYPE.fetch(:string)
|
||||
when MANAGED_TYPE_DE_CHAMP.fetch(:drop_down_list)
|
||||
CHAMP_VALUE_TYPE.fetch(:enum)
|
||||
else
|
||||
|
|
|
@ -20,13 +20,6 @@ describe Logic::ChampValue do
|
|||
end
|
||||
end
|
||||
|
||||
context 'text tdc' do
|
||||
let(:champ) { create(:champ_text, value: 'text') }
|
||||
|
||||
it { expect(champ_value(champ.stable_id).type).to eq(:string) }
|
||||
it { is_expected.to eq('text') }
|
||||
end
|
||||
|
||||
context 'integer tdc' do
|
||||
let(:champ) { create(:champ_integer_number, value: '42') }
|
||||
|
||||
|
|
|
@ -42,12 +42,6 @@ describe Logic do
|
|||
it { is_expected.to eq(ds_eq(constant(1), constant(0))) }
|
||||
end
|
||||
|
||||
context 'when string empty operator true' do
|
||||
let(:condition) { empty_operator(constant('a'), constant(true)) }
|
||||
|
||||
it { is_expected.to eq(ds_eq(constant('a'), constant(''))) }
|
||||
end
|
||||
|
||||
context 'when dropdown empty operator true' do
|
||||
let(:drop_down) { create(:type_de_champ_drop_down_list) }
|
||||
let(:first_option) { drop_down.drop_down_list_enabled_non_empty_options.first }
|
||||
|
|
|
@ -631,7 +631,13 @@ describe ProcedureRevision do
|
|||
|
||||
def second_champ = procedure.draft_revision.types_de_champ_public.second
|
||||
|
||||
let(:procedure) { create(:procedure, :with_type_de_champ, types_de_champ_count: 2) }
|
||||
let(:procedure) do
|
||||
create(:procedure).tap do |p|
|
||||
p.draft_revision.add_type_de_champ(type_champ: :integer_number, libelle: 'l1')
|
||||
p.draft_revision.add_type_de_champ(type_champ: :integer_number, libelle: 'l2')
|
||||
end
|
||||
end
|
||||
|
||||
let(:draft_revision) { procedure.draft_revision }
|
||||
let(:condition) { nil }
|
||||
|
||||
|
@ -649,7 +655,7 @@ describe ProcedureRevision do
|
|||
end
|
||||
|
||||
context 'when a champ has a valid condition: needed tdc is up in the forms' do
|
||||
let(:condition) { ds_eq(constant('oui'), champ_value(first_champ.stable_id)) }
|
||||
let(:condition) { ds_eq(champ_value(first_champ.stable_id), constant(1)) }
|
||||
|
||||
it { is_expected.to be_empty }
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue