FC ParticulierControllerSpec: callback handle empty string

This commit is contained in:
simon lehericey 2018-01-16 13:45:12 +01:00 committed by Simon Lehericey
parent 9b6b6bde97
commit 4f86b6305b
2 changed files with 15 additions and 6 deletions

View file

@ -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

View file

@ -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