From c4e427642f9aa6072445decbba29ca4166d4a8ea Mon Sep 17 00:00:00 2001 From: Damien Le Thiec Date: Mon, 19 Dec 2022 22:00:22 +0100 Subject: [PATCH] Allow prefill civility --- app/models/champs/civilite_champ.rb | 2 ++ app/models/prefill_params.rb | 3 ++- app/models/type_de_champ.rb | 3 ++- spec/factories/champ.rb | 2 +- spec/models/prefill_params_spec.rb | 1 + spec/models/type_de_champ_spec.rb | 2 +- 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/models/champs/civilite_champ.rb b/app/models/champs/civilite_champ.rb index 2277203c8..7f1fa39a4 100644 --- a/app/models/champs/civilite_champ.rb +++ b/app/models/champs/civilite_champ.rb @@ -21,6 +21,8 @@ # type_de_champ_id :integer # class Champs::CiviliteChamp < Champ + validates :value, inclusion: ["M.", "Mme"], allow_nil: true, allow_blank: false + def html_label? false end diff --git a/app/models/prefill_params.rb b/app/models/prefill_params.rb index d536deed5..bf20497f0 100644 --- a/app/models/prefill_params.rb +++ b/app/models/prefill_params.rb @@ -33,7 +33,8 @@ class PrefillParams class PrefillValue NEED_VALIDATION_TYPES_DE_CHAMPS = [ 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 diff --git a/app/models/type_de_champ.rb b/app/models/type_de_champ.rb index 774dd9e50..54cb6affa 100644 --- a/app/models/type_de_champ.rb +++ b/app/models/type_de_champ.rb @@ -259,7 +259,8 @@ class TypeDeChamp < ApplicationRecord TypeDeChamp.type_champs.fetch(:integer_number), TypeDeChamp.type_champs.fetch(:email), TypeDeChamp.type_champs.fetch(:phone), - TypeDeChamp.type_champs.fetch(:iban) + TypeDeChamp.type_champs.fetch(:iban), + TypeDeChamp.type_champs.fetch(:civilite) ]) end diff --git a/spec/factories/champ.rb b/spec/factories/champ.rb index a52f096f8..eba6e8610 100644 --- a/spec/factories/champ.rb +++ b/spec/factories/champ.rb @@ -63,7 +63,7 @@ FactoryBot.define do factory :champ_civilite, class: 'Champs::CiviliteChamp' do type_de_champ { association :type_de_champ_civilite, procedure: dossier.procedure } - value { 'Monsieur' } + value { 'M.' } end factory :champ_email, class: 'Champs::EmailChamp' do diff --git a/spec/models/prefill_params_spec.rb b/spec/models/prefill_params_spec.rb index 4f3e145a0..875cc45f5 100644 --- a/spec/models/prefill_params_spec.rb +++ b/spec/models/prefill_params_spec.rb @@ -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_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_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_integer_number, "non integer string" diff --git a/spec/models/type_de_champ_spec.rb b/spec/models/type_de_champ_spec.rb index f86c08aac..9904588da 100644 --- a/spec/models/type_de_champ_spec.rb +++ b/spec/models/type_de_champ_spec.rb @@ -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_phone 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_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_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_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_date it_behaves_like "a non-prefillable type de champ", :type_de_champ_datetime