From e7c78321d96ef680413b147ffbb6dd1e4c8b8a85 Mon Sep 17 00:00:00 2001 From: Damien Le Thiec Date: Wed, 1 Feb 2023 13:35:32 +0100 Subject: [PATCH] Fix new failing tests --- app/models/prefill_params.rb | 2 ++ spec/models/types_de_champ/prefill_type_de_champ_spec.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/prefill_params.rb b/app/models/prefill_params.rb index 6f16c1e2e..335cd005b 100644 --- a/app/models/prefill_params.rb +++ b/app/models/prefill_params.rb @@ -75,6 +75,8 @@ class PrefillParams end def repeatable_hashes + return [] unless value.is_a?(Array) + value.map.with_index do |repetition, index| row = champ.rows[index] || champ.add_row(champ.dossier_revision) JSON.parse(repetition).map do |key, value| 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 af0e3cfc9..f75fc8f1b 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 @@ -50,7 +50,7 @@ RSpec.describe TypesDeChamp::PrefillTypeDeChamp, type: :model do context 'when the type de champ is prefillable' do let(:type_de_champ) { build(:type_de_champ_email) } - it { expect(possible_values).to match([]) } + it { expect(possible_values).to match(["Une adresse email"]) } end end