add test to france connect controller
This commit is contained in:
parent
abe5d94ac5
commit
2f21b42c07
2 changed files with 23 additions and 0 deletions
|
@ -14,6 +14,8 @@ class FranceConnectController < ApplicationController
|
|||
end
|
||||
|
||||
def callback
|
||||
return redirect_to new_user_session_path unless params.has_key?(:code)
|
||||
|
||||
user_infos = FranceConnectService.retrieve_user_informations(params[:code])
|
||||
|
||||
unless user_infos.nil?
|
||||
|
|
|
@ -8,5 +8,26 @@ describe FranceConnectController, type: :controller do
|
|||
expect(response.status).to eq(302)
|
||||
end
|
||||
end
|
||||
|
||||
describe '.callback' do
|
||||
context 'when param code is missing' do
|
||||
it 'redirect to login page' do
|
||||
get :callback
|
||||
expect(response).to redirect_to(new_user_session_path)
|
||||
end
|
||||
end
|
||||
context 'when params code is present' do
|
||||
let(:code) { 'plop'}
|
||||
context 'when code is correct' do
|
||||
before do
|
||||
allow(FranceConnectService).to receive(:retrieve_user_informations).and_return(Hashie::Mash.new(email: 'patator@cake.com'))
|
||||
end
|
||||
it 'redirect to login page' do
|
||||
get :callback, code: code
|
||||
expect(response).to redirect_to(controller: 'users/dossiers', action: :index)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue