diff --git a/app/controllers/france_connect/particulier_controller.rb b/app/controllers/france_connect/particulier_controller.rb index e1c55625a..05de66dc2 100644 --- a/app/controllers/france_connect/particulier_controller.rb +++ b/app/controllers/france_connect/particulier_controller.rb @@ -29,7 +29,7 @@ class FranceConnect::ParticulierController < ApplicationController private def redirect_to_login_if_fc_aborted - if params[:code].nil? + if params[:code].empty? redirect_to new_user_session_path end end diff --git a/spec/controllers/france_connect/particulier_controller_spec.rb b/spec/controllers/france_connect/particulier_controller_spec.rb index 2d71681c6..c4a0cf68d 100644 --- a/spec/controllers/france_connect/particulier_controller_spec.rb +++ b/spec/controllers/france_connect/particulier_controller_spec.rb @@ -16,12 +16,21 @@ describe FranceConnect::ParticulierController, type: :controller do it { is_expected.to have_http_status(:redirect) } end - describe '.callback' do + 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 + subject { get :callback, params: { code: code } } + + let(:code) { nil } + + it { is_expected.to redirect_to(new_user_session_path) } + end + + context 'when param code is empty' do + subject { get :callback, params: { code: code } } + + let(:code) { '' } + + it { is_expected.to redirect_to(new_user_session_path) } end context 'when params code is present' do