added spec for dossier#update_with_france_connect
This commit is contained in:
parent
6c52c71eee
commit
d7105cb6f8
4 changed files with 17 additions and 6 deletions
|
@ -479,8 +479,8 @@ class Dossier < ApplicationRecord
|
||||||
|
|
||||||
def update_with_france_connect(fc_information)
|
def update_with_france_connect(fc_information)
|
||||||
self.individual = Individual.create(
|
self.individual = Individual.create(
|
||||||
nom: fc_information.given_name,
|
nom: fc_information.family_name,
|
||||||
prenom: fc_information.family_name,
|
prenom: fc_information.given_name,
|
||||||
gender: fc_information.gender == 'female' ? 'Mme' : 'M.'
|
gender: fc_information.gender == 'female' ? 'Mme' : 'M.'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -886,8 +886,6 @@ describe Users::DossiersController, type: :controller do
|
||||||
|
|
||||||
it { is_expected.to redirect_to dossiers_path }
|
it { is_expected.to redirect_to dossiers_path }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
context 'when user is not logged' do
|
context 'when user is not logged' do
|
||||||
it { is_expected.to have_http_status(302) }
|
it { is_expected.to have_http_status(302) }
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
FactoryBot.define do
|
FactoryBot.define do
|
||||||
factory :france_connect_information do
|
factory :france_connect_information do
|
||||||
given_name { 'plop' }
|
given_name { 'Angela Claire Louise' }
|
||||||
family_name { 'plip' }
|
family_name { 'DUBOIS' }
|
||||||
|
gender { 'female' }
|
||||||
birthdate { '1976-02-24' }
|
birthdate { '1976-02-24' }
|
||||||
france_connect_particulier_id { '1234567' }
|
france_connect_particulier_id { '1234567' }
|
||||||
email_france_connect { 'plip@octo.com' }
|
email_france_connect { 'plip@octo.com' }
|
||||||
|
|
|
@ -997,4 +997,16 @@ describe Dossier do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#update_with_france_connect' do
|
||||||
|
let(:dossier) { create(:dossier, user: user) }
|
||||||
|
let(:user_info) { create(:france_connect_information) }
|
||||||
|
|
||||||
|
it {
|
||||||
|
dossier.update_with_france_connect(user_info)
|
||||||
|
expect(dossier.individual.gender).to eq 'Mme'
|
||||||
|
expect(dossier.individual.nom).to eq user_info.family_name
|
||||||
|
expect(dossier.individual.prenom).to eq user_info.given_name
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue