Merge branch 'fix-json-endpoint-redirection' into 'master'
Bugfix: don't redirect to JSON endpoints after sign in See merge request !11561
This commit is contained in:
commit
776d4ba5c9
2 changed files with 30 additions and 1 deletions
|
@ -277,7 +277,10 @@ class Projects::IssuesController < Projects::ApplicationController
|
|||
|
||||
notice = "Please sign in to create the new issue."
|
||||
|
||||
store_location_for :user, request.fullpath
|
||||
if request.get? && !request.xhr?
|
||||
store_location_for :user, request.fullpath
|
||||
end
|
||||
|
||||
redirect_to new_user_session_path, notice: notice
|
||||
end
|
||||
end
|
||||
|
|
|
@ -156,6 +156,32 @@ describe Projects::IssuesController do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'Redirect after sign in' do
|
||||
context 'with an AJAX request' do
|
||||
it 'does not store the visited URL' do
|
||||
xhr :get,
|
||||
:show,
|
||||
format: :json,
|
||||
namespace_id: project.namespace,
|
||||
project_id: project,
|
||||
id: issue.iid
|
||||
|
||||
expect(session['user_return_to']).to be_blank
|
||||
end
|
||||
end
|
||||
|
||||
context 'without an AJAX request' do
|
||||
it 'stores the visited URL' do
|
||||
get :show,
|
||||
namespace_id: project.namespace.to_param,
|
||||
project_id: project,
|
||||
id: issue.iid
|
||||
|
||||
expect(session['user_return_to']).to eq("/#{project.namespace.to_param}/#{project.to_param}/issues/#{issue.iid}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT #update' do
|
||||
before do
|
||||
sign_in(user)
|
||||
|
|
Loading…
Reference in a new issue