From a9a9b1761181fe8c1d768d66a2c3d07c969dbcc9 Mon Sep 17 00:00:00 2001 From: Michael Cain Date: Wed, 9 Aug 2023 09:12:25 -0500 Subject: [PATCH 1/2] add logout logic with spec --- app/controllers/application_controller.rb | 7 +-- spec/routing/user_routing_spec.rb | 53 +++++++++++++---------- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 77d7fb38..29cc5cce 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -27,11 +27,8 @@ def current_user_dev # After signing out from the local application, # redirect to the logout path for the Login app def after_sign_out_path_for(resource_or_scope) - if logout_path.present? - logout_path - else - super(resource_or_scope) - end + Faraday.get(logout_path) if logout_path.present? + super(resource_or_scope) end def logout_path diff --git a/spec/routing/user_routing_spec.rb b/spec/routing/user_routing_spec.rb index b7e5eea4..26c103b7 100644 --- a/spec/routing/user_routing_spec.rb +++ b/spec/routing/user_routing_spec.rb @@ -1,33 +1,42 @@ # frozen_string_literal: true describe 'routes for users' do - describe 'GET /auth/shibboleth' do - subject { get('/auth/shibboleth') } - it do - should route_to({ - controller: 'omniauth_callbacks', - action: 'passthru' - }) + describe 'Logging in' do + describe 'GET /auth/shibboleth' do + subject { get('/auth/shibboleth') } + it do + should route_to({ + controller: 'omniauth_callbacks', + action: 'passthru' + }) + end end - end - describe 'POST /auth/shibboleth' do - subject { post('/auth/shibboleth') } - it do - should route_to({ - controller: 'omniauth_callbacks', - action: 'passthru' - }) + describe 'POST /auth/shibboleth' do + subject { post('/auth/shibboleth') } + it do + should route_to({ + controller: 'omniauth_callbacks', + action: 'passthru' + }) + end + end + + describe 'GET /auth/shibboleth/callback' do + subject { get('/auth/shibboleth/callback') } + it { should route_to({ controller: 'omniauth_callbacks', action: 'shibboleth' }) } end - end - describe 'GET /auth/shibboleth/callback' do - subject { get('/auth/shibboleth/callback') } - it { should route_to({ controller: 'omniauth_callbacks', action: 'shibboleth' }) } + describe 'POST /auth/shibboleth/callback' do + subject { post('/auth/shibboleth/callback') } + it { should route_to({ controller: 'omniauth_callbacks', action: 'shibboleth' }) } + end end - describe 'POST /auth/shibboleth/callback' do - subject { post('/auth/shibboleth/callback') } - it { should route_to({ controller: 'omniauth_callbacks', action: 'shibboleth' }) } + describe 'Logging out' do + describe 'GET /logout' do + subject { get('/logout') } + it { should route_to({ controller: 'sessions', action: 'destroy' }) } + end end end From 0d77fd2f0f079f85e6d39ae4c4012703dd47e662 Mon Sep 17 00:00:00 2001 From: Michael Cain Date: Wed, 9 Aug 2023 09:17:39 -0500 Subject: [PATCH 2/2] fix broken test --- spec/routing/user_routing_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/routing/user_routing_spec.rb b/spec/routing/user_routing_spec.rb index 26c103b7..f04b803d 100644 --- a/spec/routing/user_routing_spec.rb +++ b/spec/routing/user_routing_spec.rb @@ -36,7 +36,7 @@ describe 'Logging out' do describe 'GET /logout' do subject { get('/logout') } - it { should route_to({ controller: 'sessions', action: 'destroy' }) } + it { should route_to({ controller: 'devise/sessions', action: 'destroy' }) } end end end