Merge pull request #8305 from demarches-simplifiees/feature/prefill_civility
Allow prefill civility
This commit is contained in:
commit
ab556b9cfb
7 changed files with 11 additions and 4 deletions
|
@ -21,6 +21,8 @@
|
||||||
# type_de_champ_id :integer
|
# type_de_champ_id :integer
|
||||||
#
|
#
|
||||||
class Champs::CiviliteChamp < Champ
|
class Champs::CiviliteChamp < Champ
|
||||||
|
validates :value, inclusion: ["M.", "Mme"], allow_nil: true, allow_blank: false
|
||||||
|
|
||||||
def html_label?
|
def html_label?
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,7 +33,8 @@ class PrefillParams
|
||||||
class PrefillValue
|
class PrefillValue
|
||||||
NEED_VALIDATION_TYPES_DE_CHAMPS = [
|
NEED_VALIDATION_TYPES_DE_CHAMPS = [
|
||||||
TypeDeChamp.type_champs.fetch(:decimal_number),
|
TypeDeChamp.type_champs.fetch(:decimal_number),
|
||||||
TypeDeChamp.type_champs.fetch(:integer_number)
|
TypeDeChamp.type_champs.fetch(:integer_number),
|
||||||
|
TypeDeChamp.type_champs.fetch(:civilite)
|
||||||
]
|
]
|
||||||
|
|
||||||
attr_reader :champ, :value
|
attr_reader :champ, :value
|
||||||
|
|
|
@ -259,7 +259,8 @@ class TypeDeChamp < ApplicationRecord
|
||||||
TypeDeChamp.type_champs.fetch(:integer_number),
|
TypeDeChamp.type_champs.fetch(:integer_number),
|
||||||
TypeDeChamp.type_champs.fetch(:email),
|
TypeDeChamp.type_champs.fetch(:email),
|
||||||
TypeDeChamp.type_champs.fetch(:phone),
|
TypeDeChamp.type_champs.fetch(:phone),
|
||||||
TypeDeChamp.type_champs.fetch(:iban)
|
TypeDeChamp.type_champs.fetch(:iban),
|
||||||
|
TypeDeChamp.type_champs.fetch(:civilite)
|
||||||
])
|
])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,7 @@ fr:
|
||||||
decimal_number: Un nombre décimal
|
decimal_number: Un nombre décimal
|
||||||
integer_number: Un nombre entier
|
integer_number: Un nombre entier
|
||||||
email: Une adresse email
|
email: Une adresse email
|
||||||
|
civilite: '"M." pour Monsieur, "Mme" pour Madame'
|
||||||
phone: Un numéro de téléphone
|
phone: Un numéro de téléphone
|
||||||
iban: Un numéro Iban
|
iban: Un numéro Iban
|
||||||
yes_no: '"true" pour Oui, "false" pour Non'
|
yes_no: '"true" pour Oui, "false" pour Non'
|
||||||
|
@ -121,6 +122,7 @@ fr:
|
||||||
phone: 0612345678
|
phone: 0612345678
|
||||||
iban: FR7611315000011234567890138
|
iban: FR7611315000011234567890138
|
||||||
yes_no: "true"
|
yes_no: "true"
|
||||||
|
civilite: "M."
|
||||||
checkbox: "on"
|
checkbox: "on"
|
||||||
prefill_link_title: Lien de préremplissage (GET)
|
prefill_link_title: Lien de préremplissage (GET)
|
||||||
prefill_link_info: Copiez le lien grâce au bouton ci-dessous et remplacez les valeurs par les données dont vous disposez.
|
prefill_link_info: Copiez le lien grâce au bouton ci-dessous et remplacez les valeurs par les données dont vous disposez.
|
||||||
|
|
|
@ -63,7 +63,7 @@ FactoryBot.define do
|
||||||
|
|
||||||
factory :champ_civilite, class: 'Champs::CiviliteChamp' do
|
factory :champ_civilite, class: 'Champs::CiviliteChamp' do
|
||||||
type_de_champ { association :type_de_champ_civilite, procedure: dossier.procedure }
|
type_de_champ { association :type_de_champ_civilite, procedure: dossier.procedure }
|
||||||
value { 'Monsieur' }
|
value { 'M.' }
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :champ_email, class: 'Champs::EmailChamp' do
|
factory :champ_email, class: 'Champs::EmailChamp' do
|
||||||
|
|
|
@ -89,6 +89,7 @@ RSpec.describe PrefillParams do
|
||||||
it_behaves_like "a champ public value that is authorized", :type_de_champ_email, "value"
|
it_behaves_like "a champ public value that is authorized", :type_de_champ_email, "value"
|
||||||
it_behaves_like "a champ public value that is authorized", :type_de_champ_phone, "value"
|
it_behaves_like "a champ public value that is authorized", :type_de_champ_phone, "value"
|
||||||
it_behaves_like "a champ public value that is authorized", :type_de_champ_iban, "value"
|
it_behaves_like "a champ public value that is authorized", :type_de_champ_iban, "value"
|
||||||
|
it_behaves_like "a champ public value that is authorized", :type_de_champ_civilite, "M."
|
||||||
|
|
||||||
it_behaves_like "a champ public value that is unauthorized", :type_de_champ_decimal_number, "non decimal string"
|
it_behaves_like "a champ public value that is unauthorized", :type_de_champ_decimal_number, "non decimal string"
|
||||||
it_behaves_like "a champ public value that is unauthorized", :type_de_champ_integer_number, "non integer string"
|
it_behaves_like "a champ public value that is unauthorized", :type_de_champ_integer_number, "non integer string"
|
||||||
|
|
|
@ -242,13 +242,13 @@ describe TypeDeChamp do
|
||||||
it_behaves_like "a prefillable type de champ", :type_de_champ_email
|
it_behaves_like "a prefillable type de champ", :type_de_champ_email
|
||||||
it_behaves_like "a prefillable type de champ", :type_de_champ_phone
|
it_behaves_like "a prefillable type de champ", :type_de_champ_phone
|
||||||
it_behaves_like "a prefillable type de champ", :type_de_champ_iban
|
it_behaves_like "a prefillable type de champ", :type_de_champ_iban
|
||||||
|
it_behaves_like "a prefillable type de champ", :type_de_champ_civilite
|
||||||
|
|
||||||
it_behaves_like "a non-prefillable type de champ", :type_de_champ_number
|
it_behaves_like "a non-prefillable type de champ", :type_de_champ_number
|
||||||
it_behaves_like "a non-prefillable type de champ", :type_de_champ_communes
|
it_behaves_like "a non-prefillable type de champ", :type_de_champ_communes
|
||||||
it_behaves_like "a non-prefillable type de champ", :type_de_champ_dossier_link
|
it_behaves_like "a non-prefillable type de champ", :type_de_champ_dossier_link
|
||||||
it_behaves_like "a non-prefillable type de champ", :type_de_champ_checkbox
|
it_behaves_like "a non-prefillable type de champ", :type_de_champ_checkbox
|
||||||
it_behaves_like "a non-prefillable type de champ", :type_de_champ_titre_identite
|
it_behaves_like "a non-prefillable type de champ", :type_de_champ_titre_identite
|
||||||
it_behaves_like "a non-prefillable type de champ", :type_de_champ_civilite
|
|
||||||
it_behaves_like "a non-prefillable type de champ", :type_de_champ_yes_no
|
it_behaves_like "a non-prefillable type de champ", :type_de_champ_yes_no
|
||||||
it_behaves_like "a non-prefillable type de champ", :type_de_champ_date
|
it_behaves_like "a non-prefillable type de champ", :type_de_champ_date
|
||||||
it_behaves_like "a non-prefillable type de champ", :type_de_champ_datetime
|
it_behaves_like "a non-prefillable type de champ", :type_de_champ_datetime
|
||||||
|
|
Loading…
Reference in a new issue