Commit 267f71b1 authored by David O'Regan's avatar David O'Regan

Merge branch '322980-fix-sign-out-on-error-pages' into 'master'

Fix "sign out" button in error pages

See merge request gitlab-org/gitlab!59030
parents 561e9e6a edc9564a
......@@ -4,7 +4,8 @@
= link_to s_('Nav|Home'), root_path
%li
- if current_user
= link_to s_('Nav|Sign out and sign in with a different account'), destroy_user_session_path, method: :post
= link_to s_('Nav|Sign out and sign in with a different account'), '#', id: 'sign_out_link'
%form{ action: destroy_user_session_path, method: :post, id: 'sign_out_form' }
- else
= link_to s_('Nav|Sign In / Register'), new_session_path(:user, redirect_to_referer: 'yes')
%li
......
......@@ -20,4 +20,10 @@
history.back();
});
}
// We do not have rails_ujs here, so we're manually making a link trigger a form submit.
document.getElementById('sign_out_link').addEventListener('click', function(e) {
e.preventDefault();
document.getElementById('sign_out_form').submit();
});
}());
---
title: Fix sign out button in error pages
merge_request: 59030
author:
type: fixed
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe 'Error Pages' do
RSpec.describe 'Error Pages', :js do
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
......@@ -14,7 +14,12 @@ RSpec.describe 'Error Pages' do
it 'shows nav links' do
expect(page).to have_link("Home", href: root_path)
expect(page).to have_link("Help", href: help_path)
expect(page).to have_link(nil, href: destroy_user_session_path)
end
it 'allows user to sign out' do
click_link 'Sign out and sign in with a different account'
expect(page).to have_current_path(new_user_session_path)
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment