Commit 78d2375d authored by Kerri Miller's avatar Kerri Miller

Merge branch '267583-fix-storing-of-issue-json-for-redirect' into 'master'

Fix redirects to issue sidebar JSON after sign in

See merge request gitlab-org/gitlab!45194
parents fb1f1e48 6495618a
...@@ -326,7 +326,7 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -326,7 +326,7 @@ class Projects::IssuesController < Projects::ApplicationController
end end
def store_uri def store_uri
if request.get? && !request.xhr? if request.get? && request.format.html?
store_location_for :user, request.fullpath store_location_for :user, request.fullpath
end end
end end
......
---
title: Fix redirects to issue sidebar JSON when visiting the login page
merge_request: 45194
author:
type: fixed
...@@ -388,15 +388,23 @@ RSpec.describe Projects::IssuesController do ...@@ -388,15 +388,23 @@ RSpec.describe Projects::IssuesController do
# Rails router. A controller-style spec matches the wrong route, and # Rails router. A controller-style spec matches the wrong route, and
# session['user_return_to'] becomes incorrect. # session['user_return_to'] becomes incorrect.
describe 'Redirect after sign in', type: :request do describe 'Redirect after sign in', type: :request do
context 'with an AJAX request' do before_all do
project.add_developer(user)
end
before do
login_as(user)
end
context 'with a JSON request' do
it 'does not store the visited URL' do it 'does not store the visited URL' do
get project_issue_path(project, issue), xhr: true get project_issue_path(project, issue, format: :json)
expect(session['user_return_to']).to be_blank expect(session['user_return_to']).to be_blank
end end
end end
context 'without an AJAX request' do context 'with an HTML request' do
it 'stores the visited URL' do it 'stores the visited URL' do
get project_issue_path(project, issue) get project_issue_path(project, issue)
......
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