Commit 0b21a71a authored by Sean McGivern's avatar Sean McGivern

Merge branch 'fix-singin-redirect-for-fork-new' into 'master'

Fixing the issue of visiting a project fork url giving 500 error when not signed…

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/24302

See merge request !7392
parents 3344e1e8 5bc19dec
......@@ -4,6 +4,7 @@ class Projects::ForksController < Projects::ApplicationController
# Authorize
before_action :require_non_empty_project
before_action :authorize_download_code!
before_action :authenticate_user!, only: [:new, :create]
def index
base_query = project.forks.includes(:creator)
......
---
title: Fixing the issue of the project fork url giving 500 when not signed instead
of being redirected to sign in page
merge_request:
author: Cagdas Gerede
......@@ -67,4 +67,62 @@ describe Projects::ForksController do
end
end
end
describe 'GET new' do
def get_new
get :new,
namespace_id: project.namespace.to_param,
project_id: project.to_param
end
context 'when user is signed in' do
it 'responds with status 200' do
sign_in(user)
get_new
expect(response).to have_http_status(200)
end
end
context 'when user is not signed in' do
it 'redirects to the sign-in page' do
sign_out(user)
get_new
expect(response).to redirect_to(new_user_session_path)
end
end
end
describe 'POST create' do
def post_create
post :create,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
namespace_key: user.namespace.id
end
context 'when user is signed in' do
it 'responds with status 302' do
sign_in(user)
post_create
expect(response).to have_http_status(302)
expect(response).to redirect_to(namespace_project_import_path(user.namespace, project))
end
end
context 'when user is not signed in' do
it 'redirects to the sign-in page' do
sign_out(user)
post_create
expect(response).to redirect_to(new_user_session_path)
end
end
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