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