FC ParticulierControllerSpec: simplify ... well you know
This commit is contained in:
parent
570f779bb2
commit
69c121a879
1 changed files with 7 additions and 21 deletions
|
@ -69,43 +69,29 @@ describe FranceConnect::ParticulierController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when france_connect_particulier_id does not exist in database' do
|
context 'when france_connect_particulier_id does not exist in database' do
|
||||||
let(:last_france_connect_information) { FranceConnectInformation.last }
|
|
||||||
|
|
||||||
it { expect { subject }.to change { FranceConnectInformation.count }.by(1) }
|
it { expect { subject }.to change { FranceConnectInformation.count }.by(1) }
|
||||||
|
|
||||||
describe 'FranceConnectInformation attributs' do
|
describe 'FranceConnectInformation attributs' do
|
||||||
before do
|
let(:stored_fci) { FranceConnectInformation.last }
|
||||||
get :callback, params: {code: code}
|
|
||||||
end
|
|
||||||
|
|
||||||
subject { last_france_connect_information }
|
before { subject }
|
||||||
|
|
||||||
it { expect(subject.gender).to eq gender }
|
it { expect(stored_fci).to have_attributes(user_info.merge(birthdate: DateTime.parse(birthdate))) }
|
||||||
it { expect(subject.given_name).to eq given_name }
|
|
||||||
it { expect(subject.family_name).to eq family_name }
|
|
||||||
it { expect(subject.email_france_connect).to eq email }
|
|
||||||
it { expect(subject.birthdate.to_time.to_i).to eq birthdate.to_time.to_i }
|
|
||||||
it { expect(subject.birthplace).to eq birthplace }
|
|
||||||
it { expect(subject.france_connect_particulier_id).to eq france_connect_particulier_id }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(subject).to redirect_to(root_path) }
|
it { is_expected.to redirect_to(root_path) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when code is not correct' do
|
context 'when code is not correct' do
|
||||||
before do
|
before do
|
||||||
allow(FranceConnectService).to receive(:retrieve_user_informations_particulier) { raise Rack::OAuth2::Client::Error.new(500, error: 'Unknown') }
|
allow(FranceConnectService).to receive(:retrieve_user_informations_particulier) { raise Rack::OAuth2::Client::Error.new(500, error: 'Unknown') }
|
||||||
get :callback, params: {code: code}
|
subject
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirect to login page' do
|
it { expect(response).to redirect_to(new_user_session_path) }
|
||||||
expect(response).to redirect_to(new_user_session_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'display error message' do
|
it { expect(flash[:alert]).to be_present }
|
||||||
expect(flash[:alert]).to be_present
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue