Skip to content

Commit

Permalink
Remove logout link, controller method, route, and specs
Browse files Browse the repository at this point in the history
  • Loading branch information
jgreben committed Aug 30, 2018
1 parent a9d36b5 commit a8afba9
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 36 deletions.
7 changes: 1 addition & 6 deletions app/controllers/authentication_controller.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
###
# Controller for handling login/logout and redirecting with flash messages.
# Controller for handling login and redirecting with flash messages.
###
class AuthenticationController < ApplicationController
def login
flash[:success] = 'You have been successfully logged in.'
redirect_to params[:referrer] || :back
end

def logout
flash[:notice] = 'You have been successfully logged out.'
redirect_to params[:referrer] || :back
end
end
1 change: 0 additions & 1 deletion app/views/shared/_top_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

<div class="header-links" id="login_id" data="<%= user_id %>">
<% if webauth_user? %>
<%= link_to "#{user_id}: Logout", logout_path(referrer: root_path) %>
<% if can? :manage, AuthorizedUser %>
<%= link_to "Administer users", authorized_users_index_path %>
<% end %>
Expand Down
1 change: 0 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
get 'home/index'

get 'webauth/login' => 'authentication#login', as: :login
get 'webauth/logout' => 'authentication#logout', as: :logout

resources :accession_numbers, except: :destroy do
member do
Expand Down
14 changes: 0 additions & 14 deletions spec/controllers/authentication_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,4 @@
expect(flash[:success]).to eq 'You have been successfully logged in.'
end
end
describe 'logout' do
it 'should redirect back to the provided referrer' do
get :logout, referrer: '/'
expect(response).to redirect_to('/')
end
it 'should redirect back when there is no provided referrer' do
get :logout
expect(response).to redirect_to('https://example.com')
end
it 'should have a flash notice message informing the user they logged out' do
get :logout
expect(flash[:notice]).to eq 'You have been successfully logged out.'
end
end
end
14 changes: 0 additions & 14 deletions spec/views/shared/_top_navbar.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,4 @@
expect(rendered).to have_css('a', text: 'Login')
end
end
describe 'logout link' do
before do
stub_current_user_for_view { FactoryBot.create(:authorized_user) }
stub_user_id_for_view { FactoryBot.create(:authorized_user).user_id }
stub_webauth_user_for_view { FactoryBot.create(:authorized_user) }
render
end
it 'should have a logout link if there is a user' do
expect(rendered).to have_css('a', text: 'testuser: Logout')
end
it 'should redirect users back to the home page of the app' do
expect(rendered).to have_link('testuser: Logout', href: '/webauth/logout?referrer=%2F')
end
end
end

0 comments on commit a8afba9

Please sign in to comment.