From 6231c75e07f3ae5dc2b5c6910ff5ee9264b41e60 Mon Sep 17 00:00:00 2001 From: Damien Le Thiec Date: Thu, 16 Feb 2023 16:58:55 +0100 Subject: [PATCH] Fix tests conflicts --- app/models/prefill_params.rb | 1 - app/models/types_de_champ/prefill_type_de_champ.rb | 4 ---- spec/models/prefill_params_spec.rb | 6 +++--- spec/models/types_de_champ/prefill_type_de_champ_spec.rb | 8 -------- 4 files changed, 3 insertions(+), 16 deletions(-) diff --git a/app/models/prefill_params.rb b/app/models/prefill_params.rb index 52f8ce1e6..63ff0b25d 100644 --- a/app/models/prefill_params.rb +++ b/app/models/prefill_params.rb @@ -70,6 +70,5 @@ class PrefillParams champ.assign_attributes(champ_attributes) champ.valid?(:prefill) end - end end diff --git a/app/models/types_de_champ/prefill_type_de_champ.rb b/app/models/types_de_champ/prefill_type_de_champ.rb index 6a4e6a047..e389315fa 100644 --- a/app/models/types_de_champ/prefill_type_de_champ.rb +++ b/app/models/types_de_champ/prefill_type_de_champ.rb @@ -72,8 +72,4 @@ class TypesDeChamp::PrefillTypeDeChamp < SimpleDelegator def description @description ||= I18n.t("views.prefill_descriptions.edit.possible_values.#{type_champ}_html", default: nil)&.html_safe # rubocop:disable Rails/OutputSafety end - - def transform_value_to_assignable_attributes(value) - { value: value } - end end diff --git a/spec/models/prefill_params_spec.rb b/spec/models/prefill_params_spec.rb index 1842b9900..53f15ed17 100644 --- a/spec/models/prefill_params_spec.rb +++ b/spec/models/prefill_params_spec.rb @@ -146,7 +146,7 @@ RSpec.describe PrefillParams do let(:type_de_champ_child_value) { "value" } let(:type_de_champ_child_value2) { "value2" } - let(:params) { { "champ_#{type_de_champ.to_typed_id}" => ["{\"#{type_de_champ_child.libelle}\":\"#{type_de_champ_child_value}\"}", "{\"#{type_de_champ_child.libelle}\":\"#{type_de_champ_child_value2}\"}"] } } + let(:params) { { "champ_#{type_de_champ.to_typed_id}" => ["{\"#{type_de_champ_child.to_typed_id}\":\"#{type_de_champ_child_value}\"}", "{\"#{type_de_champ_child.to_typed_id}\":\"#{type_de_champ_child_value2}\"}"] } } it "builds an array of hash(id, value) matching the given params" do expect(prefill_params_array).to match([{ id: type_de_champ_child.champ.first.id, value: type_de_champ_child_value }, { id: type_de_champ_child.champ.second.id, value: type_de_champ_child_value2 }]) @@ -180,7 +180,7 @@ RSpec.describe PrefillParams do let(:type_de_champ_child_value) { "value" } let(:type_de_champ_child_value2) { "value2" } - let(:params) { { "champ_#{type_de_champ.to_typed_id}" => ["{\"#{type_de_champ_child.libelle}\":\"#{type_de_champ_child_value}\"}", "{\"#{type_de_champ_child.libelle}\":\"#{type_de_champ_child_value2}\"}"] } } + let(:params) { { "champ_#{type_de_champ.to_typed_id}" => ["{\"#{type_de_champ_child.to_typed_id}\":\"#{type_de_champ_child_value}\"}", "{\"#{type_de_champ_child.to_typed_id}\":\"#{type_de_champ_child_value2}\"}"] } } it "builds an array of hash(id, value) matching the given params" do expect(prefill_params_array).to match([{ id: type_de_champ_child.champ.first.id, value: type_de_champ_child_value }, { id: type_de_champ_child.champ.second.id, value: type_de_champ_child_value2 }]) @@ -227,7 +227,7 @@ RSpec.describe PrefillParams do end end - context "when the public type de champ is unauthorized because of wrong value libelle (repetition)" do + context "when the public type de champ is unauthorized because of wrong value typed_id (repetition)" do let(:types_de_champ_public) { [{ type: :repetition, children: [{ type: :text }] }] } let(:type_de_champ) { procedure.published_revision.types_de_champ_public.first } let(:type_de_champ_child) { procedure.published_revision.children_of(type_de_champ).first } diff --git a/spec/models/types_de_champ/prefill_type_de_champ_spec.rb b/spec/models/types_de_champ/prefill_type_de_champ_spec.rb index 45ea7dce9..a4b1655e5 100644 --- a/spec/models/types_de_champ/prefill_type_de_champ_spec.rb +++ b/spec/models/types_de_champ/prefill_type_de_champ_spec.rb @@ -137,12 +137,4 @@ RSpec.describe TypesDeChamp::PrefillTypeDeChamp, type: :model do it { is_expected.to match({ id: champ.id, value: value }) } end - - describe '#transform_value_to_assignable_attributes' do - let(:type_de_champ) { build(:type_de_champ_email) } - let(:value) { "any@email.org" } - subject(:transform_value_to_assignable_attributes) { described_class.build(type_de_champ).transform_value_to_assignable_attributes(value) } - - it { is_expected.to match({ value: value }) } - end end