introduce constants for M./Mme

This commit is contained in:
clemkeirua 2019-08-01 09:34:26 +02:00
parent d7105cb6f8
commit 1e6847bc6f
2 changed files with 12 additions and 5 deletions

View file

@ -478,11 +478,7 @@ class Dossier < ApplicationRecord
end
def update_with_france_connect(fc_information)
self.individual = Individual.create(
nom: fc_information.family_name,
prenom: fc_information.given_name,
gender: fc_information.gender == 'female' ? 'Mme' : 'M.'
)
self.individual = Individual.create_from_france_connect(fc_information)
end
private

View file

@ -5,4 +5,15 @@ class Individual < ApplicationRecord
validates :gender, presence: true, allow_nil: false, on: :update
validates :nom, presence: true, allow_blank: false, allow_nil: false, on: :update
validates :prenom, presence: true, allow_blank: false, allow_nil: false, on: :update
GENDER_MALE = 'M.'
GENDER_FEMALE = 'Mme'
def self.create_from_france_connect(fc_information)
create(
nom: fc_information.family_name,
prenom: fc_information.given_name,
gender: fc_information.gender == 'female' ? GENDER_FEMALE : GENDER_MALE
)
end
end