Commit a8f94dbf authored by Stan Hu's avatar Stan Hu

Merge branch 'aa-redirect-to-onboarding-board-if-available' into 'master'

Smart redirect to onboarding  project after import

See merge request gitlab-org/gitlab!53246
parents fb22ec0f 3b2d7137
......@@ -50,6 +50,7 @@ Rails.application.routes.draw do
resource :welcome, only: [:show, :update], controller: 'welcome' do
Gitlab.ee do
get :trial_getting_started, on: :collection
get :trial_onboarding_board, on: :collection
end
end
......
......@@ -5,6 +5,8 @@ module EE
module WelcomeController
extend ::Gitlab::Utils::Override
TRIAL_ONBOARDING_BOARD_NAME = 'GitLab onboarding'
def trial_getting_started
project = learn_gitlab_project
return access_denied! unless current_user.id == project.creator_id
......@@ -12,6 +14,15 @@ module EE
render locals: { learn_gitlab_project: learn_gitlab_project }
end
def trial_onboarding_board
project = learn_gitlab_project
return access_denied! unless current_user.id == project.creator_id
board = project.boards.find_by_name(TRIAL_ONBOARDING_BOARD_NAME)
path = board ? project_board_path(project, board) : project_boards_path(project)
redirect_to path
end
private
override :update_params
......
......@@ -8,4 +8,4 @@
%h2.gl-text-center.gl-mt-5= _('Get started with GitLab')
%p.gl-text-center.gl-mb-5= _('We created a sandbox project that will help you learn the basics of GitLab. You’ll be guided by issues in an issue board. You can go through the issues at your own pace.')
= image_tag 'board-intro.svg', class: 'gl-w-full'
= link_to s_("Ok, let's go"), project_boards_path(learn_gitlab_project), class: 'btn btn-success gl-button gl-mt-5'
= link_to s_("Ok, let's go"), trial_onboarding_board_users_sign_up_welcome_path(learn_gitlab_project_id: learn_gitlab_project.id), class: 'btn btn-success gl-button gl-mt-5'
......@@ -33,12 +33,58 @@ RSpec.describe Registrations::WelcomeController do
sign_in(another_user)
end
it 'sets the learn_gitlab_project and renders' do
it 'renders 404' do
subject
is_expected.to have_gitlab_http_status(:not_found)
end
end
end
describe '#trial_onboarding_board' do
subject(:trial_onboarding_board) do
get :trial_onboarding_board, params: { learn_gitlab_project_id: project.id }
end
context 'without a signed in user' do
it { is_expected.to redirect_to new_user_session_path }
end
context 'with any other user signed in except the creator' do
before do
sign_in(another_user)
end
it 'renders 404' do
subject
is_expected.to have_gitlab_http_status(:not_found)
end
end
context 'with the creator user signed' do
before do
sign_in(user)
end
context 'gitlab onboarding project is not imported yet' do
it 'redirects to the boards path' do
subject
is_expected.to redirect_to(project_boards_path(project))
end
end
context 'gitlab onboarding project is imported yet' do
let_it_be(:board) { create(:board, project: project, name: EE::Registrations::WelcomeController::TRIAL_ONBOARDING_BOARD_NAME) }
it 'redirects to the board path' do
subject
is_expected.to redirect_to(project_board_path(project, board))
end
end
end
end
describe '#update' do
......
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