Merge branch 'main' into feature/prefill_repetible
This commit is contained in:
commit
539b9e4f10
6 changed files with 18 additions and 5 deletions
|
@ -68,7 +68,7 @@ class PrefillParams
|
|||
def champ_attributes
|
||||
TypesDeChamp::PrefillTypeDeChamp
|
||||
.build(champ.type_de_champ)
|
||||
.to_assignable_attributes(value)
|
||||
.to_assignable_attributes(champ, value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -72,4 +72,8 @@ 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
|
||||
|
|
|
@ -136,6 +136,7 @@ en:
|
|||
drop_down_list_other_html: Any value
|
||||
repetition_html: A array of hashes with possible values for each field of the repetition.
|
||||
regions_html: An <a href="https://fr.wikipedia.org/wiki/R%C3%A9gion_fran%C3%A7aise" target="_blank" rel="noopener noreferrer">INSEE region code</a>
|
||||
regions_html: An <a href="https://fr.wikipedia.org/wiki/R%C3%A9gion_fran%C3%A7aise" target="_blank" rel="noopener noreferrer">INSEE region code</a>
|
||||
epci_html: An array of the department code and the <a href="https://geo.api.gouv.fr/epcis" target="_blank" rel="noopener noreferrer">EPCI one</a>.
|
||||
examples:
|
||||
title: Example
|
||||
|
|
|
@ -137,4 +137,12 @@ 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
|
||||
|
|
|
@ -9,17 +9,17 @@ describe 'Prefilling a dossier (with a GET request):' do
|
|||
let(:type_de_champ_text) { create(:type_de_champ_text, procedure: procedure) }
|
||||
let(:type_de_champ_phone) { create(:type_de_champ_phone, procedure: procedure) }
|
||||
let(:type_de_champ_datetime) { create(:type_de_champ_datetime, procedure: procedure) }
|
||||
let(:type_de_champ_epci) { create(:type_de_champ_epci, procedure: procedure) }
|
||||
let(:type_de_champ_repetition) { create(:type_de_champ_repetition, :with_types_de_champ, procedure: procedure) }
|
||||
let(:text_value) { "My Neighbor Totoro is the best movie ever" }
|
||||
let(:phone_value) { "invalid phone value" }
|
||||
let(:datetime_value) { "2023-02-01T10:32" }
|
||||
let(:epci_value) { ['01', '200029999'] }
|
||||
let(:sub_type_de_champs_repetition) { type_de_champ_repetition.active_revision_type_de_champ.revision_types_de_champ.map(&:type_de_champ) }
|
||||
let(:text_repetition_libelle) { sub_type_de_champs_repetition.first.libelle }
|
||||
let(:integer_repetition_libelle) { sub_type_de_champs_repetition.second.libelle }
|
||||
let(:text_repetition_value) { "First repetition text" }
|
||||
let(:integer_repetition_value) { "42" }
|
||||
let(:type_de_champ_epci) { create(:type_de_champ_epci, procedure: procedure) }
|
||||
let(:epci_value) { ['01', '200029999'] }
|
||||
|
||||
before do
|
||||
allow(Rails).to receive(:cache).and_return(memory_store)
|
||||
|
|
|
@ -9,17 +9,17 @@ describe 'Prefilling a dossier (with a POST request):' do
|
|||
let(:type_de_champ_text) { create(:type_de_champ_text, procedure: procedure) }
|
||||
let(:type_de_champ_phone) { create(:type_de_champ_phone, procedure: procedure) }
|
||||
let(:type_de_champ_datetime) { create(:type_de_champ_datetime, procedure: procedure) }
|
||||
let(:type_de_champ_epci) { create(:type_de_champ_epci, procedure: procedure) }
|
||||
let(:type_de_champ_repetition) { create(:type_de_champ_repetition, :with_types_de_champ, procedure: procedure) }
|
||||
let(:text_value) { "My Neighbor Totoro is the best movie ever" }
|
||||
let(:phone_value) { "invalid phone value" }
|
||||
let(:datetime_value) { "2023-02-01T10:32" }
|
||||
let(:epci_value) { ['01', '200029999'] }
|
||||
let(:sub_type_de_champs_repetition) { type_de_champ_repetition.active_revision_type_de_champ.revision_types_de_champ.map(&:type_de_champ) }
|
||||
let(:text_repetition_libelle) { sub_type_de_champs_repetition.first.libelle }
|
||||
let(:integer_repetition_libelle) { sub_type_de_champs_repetition.second.libelle }
|
||||
let(:text_repetition_value) { "First repetition text" }
|
||||
let(:integer_repetition_value) { "42" }
|
||||
let(:type_de_champ_epci) { create(:type_de_champ_epci, procedure: procedure) }
|
||||
let(:epci_value) { ['01', '200029999'] }
|
||||
|
||||
before do
|
||||
allow(Rails).to receive(:cache).and_return(memory_store)
|
||||
|
|
Loading…
Reference in a new issue