Commit edc9564a authored by Paul Slaughter's avatar Paul Slaughter

Fix "sign out" button in error pages

- Added some vanilla JS since we don't have
  rails_ujs here. If rails_ujs was here we could
  simple use data-method.
parent 16e74e4e
......@@ -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