Use enum to the fullest with User.loged_in_with_france_connects
This commit is contained in:
parent
606b56033a
commit
16a719922b
4 changed files with 6 additions and 6 deletions
|
@ -42,7 +42,7 @@ class FranceConnect::ParticulierController < ApplicationController
|
|||
|
||||
sign_in user
|
||||
|
||||
user.update_attribute('loged_in_with_france_connect', 'particulier')
|
||||
user.update_attribute('loged_in_with_france_connect', User.loged_in_with_france_connects.fetch(:particulier))
|
||||
|
||||
redirect_to stored_location_for(current_user) || root_path(current_user)
|
||||
end
|
||||
|
|
|
@ -49,7 +49,7 @@ class Users::SessionsController < Sessions::SessionsController
|
|||
sign_out :user
|
||||
|
||||
case connected_with_france_connect
|
||||
when 'particulier'
|
||||
when User.loged_in_with_france_connects.fetch(:particulier)
|
||||
redirect_to FRANCE_CONNECT[:particulier][:logout_endpoint]
|
||||
return
|
||||
end
|
||||
|
|
|
@ -53,7 +53,7 @@ describe FranceConnect::ParticulierController, type: :controller do
|
|||
|
||||
it do
|
||||
subject
|
||||
expect(user.reload.loged_in_with_france_connect).to eq('particulier')
|
||||
expect(user.reload.loged_in_with_france_connect).to eq(User.loged_in_with_france_connects.fetch(:particulier))
|
||||
end
|
||||
|
||||
context 'and the user has a stored location' do
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Users::SessionsController, type: :controller do
|
||||
let(:loged_in_with_france_connect) { 'particulier' }
|
||||
let(:loged_in_with_france_connect) { User.loged_in_with_france_connects.fetch(:particulier) }
|
||||
let(:user) { create(:user, loged_in_with_france_connect: loged_in_with_france_connect) }
|
||||
|
||||
before do
|
||||
|
@ -115,7 +115,7 @@ describe Users::SessionsController, type: :controller do
|
|||
end
|
||||
|
||||
context 'when user is connect with france connect particulier' do
|
||||
let(:loged_in_with_france_connect) { 'particulier' }
|
||||
let(:loged_in_with_france_connect) { User.loged_in_with_france_connects.fetch(:particulier) }
|
||||
|
||||
it 'redirect to france connect logout page' do
|
||||
expect(response).to redirect_to(FRANCE_CONNECT[:particulier][:logout_endpoint])
|
||||
|
@ -158,7 +158,7 @@ describe Users::SessionsController, type: :controller do
|
|||
end
|
||||
|
||||
it 'signs user out from france connect' do
|
||||
user.update(loged_in_with_france_connect: 'particulier')
|
||||
user.update(loged_in_with_france_connect: User.loged_in_with_france_connects.fetch(:particulier))
|
||||
sign_in user
|
||||
delete :destroy
|
||||
expect(@response.headers["Location"]).to eq(FRANCE_CONNECT[:particulier][:logout_endpoint])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue