Fix tests conflicts

This commit is contained in:
Damien Le Thiec 2023-02-16 16:58:55 +01:00
parent 96b9ec3f42
commit 6231c75e07
4 changed files with 3 additions and 16 deletions

View file

@ -70,6 +70,5 @@ class PrefillParams
champ.assign_attributes(champ_attributes)
champ.valid?(:prefill)
end
end
end

View file

@ -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

View file

@ -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 }

View file

@ -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