Skip to content

Commit

Permalink
add logout logic with spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Cain committed Aug 9, 2023
1 parent 5531dc8 commit 1049c5b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 28 deletions.
9 changes: 3 additions & 6 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@ def after_sign_in_path_for(resource)
def current_user_dev
@current_user_dev ||= User.find_by_username('admin') || User.new
end
alias current_user current_user_dev if Rails.env.development?
# alias current_user current_user_dev if Rails.env.development?

# 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
Expand Down
53 changes: 31 additions & 22 deletions spec/routing/user_routing_spec.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1049c5b

Please sign in to comment.