Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
9adf18c2
Commit
9adf18c2
authored
May 29, 2020
by
Alex Buijs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create Learn GitLab project
And redirect to experience_level page
parent
619b7728
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
11 deletions
+25
-11
ee/app/controllers/registrations/projects_controller.rb
ee/app/controllers/registrations/projects_controller.rb
+12
-1
ee/spec/controllers/registrations/projects_controller_spec.rb
...pec/controllers/registrations/projects_controller_spec.rb
+10
-7
lib/gitlab/experimentation.rb
lib/gitlab/experimentation.rb
+3
-3
vendor/project_templates/learn_gitlab.tar.gz
vendor/project_templates/learn_gitlab.tar.gz
+0
-0
No files found.
ee/app/controllers/registrations/projects_controller.rb
View file @
9adf18c2
...
@@ -15,7 +15,8 @@ module Registrations
...
@@ -15,7 +15,8 @@ module Registrations
@project
=
::
Projects
::
CreateService
.
new
(
current_user
,
project_params
).
execute
@project
=
::
Projects
::
CreateService
.
new
(
current_user
,
project_params
).
execute
if
@project
.
saved?
if
@project
.
saved?
redirect_to
project_path
(
@project
)
create_learn_gitlab_project
redirect_to
users_sign_up_experience_level_path
else
else
render
:new
render
:new
end
end
...
@@ -23,6 +24,16 @@ module Registrations
...
@@ -23,6 +24,16 @@ module Registrations
private
private
def
create_learn_gitlab_project
File
.
open
(
learn_gitlab_template_path
)
do
|
archive
|
::
Projects
::
GitlabProjectsImportService
.
new
(
current_user
,
namespace_id:
@project
.
namespace_id
,
file:
archive
,
name:
s_
(
'Learn GitLab'
)).
execute
end
end
def
learn_gitlab_template_path
Rails
.
root
.
join
(
'vendor'
,
'project_templates'
,
'learn_gitlab.tar.gz'
)
end
def
check_experiment_enabled
def
check_experiment_enabled
access_denied!
unless
experiment_enabled?
(
:onboarding_issues
)
access_denied!
unless
experiment_enabled?
(
:onboarding_issues
)
end
end
...
...
ee/spec/controllers/registrations/projects_controller_spec.rb
View file @
9adf18c2
...
@@ -4,7 +4,7 @@ require 'spec_helper'
...
@@ -4,7 +4,7 @@ require 'spec_helper'
describe
Registrations
::
ProjectsController
do
describe
Registrations
::
ProjectsController
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:namespace
)
{
create
(
:group
,
path:
'group-path'
)
}
let_it_be
(
:namespace
)
{
create
(
:group
)
}
describe
'GET #new'
do
describe
'GET #new'
do
subject
{
get
:new
}
subject
{
get
:new
}
...
@@ -50,7 +50,7 @@ describe Registrations::ProjectsController do
...
@@ -50,7 +50,7 @@ describe Registrations::ProjectsController do
describe
'POST #create'
do
describe
'POST #create'
do
subject
{
post
:create
,
params:
{
project:
params
}
}
subject
{
post
:create
,
params:
{
project:
params
}
}
let
(
:params
)
{
{
namespace_id:
namespace
.
id
,
name:
'
Project name
'
,
path:
'project-path'
,
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
}
}
let
(
:params
)
{
{
namespace_id:
namespace
.
id
,
name:
'
New project
'
,
path:
'project-path'
,
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
}
}
context
'with an unauthenticated user'
do
context
'with an unauthenticated user'
do
it
{
is_expected
.
to
have_gitlab_http_status
(
:redirect
)
}
it
{
is_expected
.
to
have_gitlab_http_status
(
:redirect
)
}
...
@@ -64,12 +64,15 @@ describe Registrations::ProjectsController do
...
@@ -64,12 +64,15 @@ describe Registrations::ProjectsController do
stub_experiment_for_user
(
onboarding_issues:
true
)
stub_experiment_for_user
(
onboarding_issues:
true
)
end
end
it
'creates a project'
do
it
'creates a new project, a "Learn GitLab" project and redirects to the experience level page'
do
expect
{
subject
}.
to
change
{
Project
.
count
}.
by
(
1
)
expect
{
subject
}.
to
change
{
namespace
.
projects
.
pluck
(
:name
)
}.
from
([]).
to
([
'New project'
,
s_
(
'Learn GitLab'
)])
end
it
{
is_expected
.
to
have_gitlab_http_status
(
:redirect
)
}
Sidekiq
::
Worker
.
drain_all
it
{
is_expected
.
to
redirect_to
(
'/group-path/project-path'
)
}
expect
(
subject
).
to
have_gitlab_http_status
(
:redirect
)
expect
(
subject
).
to
redirect_to
(
users_sign_up_experience_level_path
)
expect
(
namespace
.
projects
.
find_by_name
(
s_
(
'Learn GitLab'
))).
to
be_import_finished
end
context
'when the project cannot be saved'
do
context
'when the project cannot be saved'
do
let
(
:params
)
{
{
name:
''
,
path:
''
}
}
let
(
:params
)
{
{
name:
''
,
path:
''
}
}
...
...
lib/gitlab/experimentation.rb
View file @
9adf18c2
...
@@ -12,8 +12,8 @@
...
@@ -12,8 +12,8 @@
#
#
# To enable the experiment for 10% of the users:
# To enable the experiment for 10% of the users:
#
#
# chatops: `/chatops run feature set experiment_key_experiment_percentage 10
--actors
`
# chatops: `/chatops run feature set experiment_key_experiment_percentage 10`
# console: `Feature.enable_percentage_of_
actors
(:experiment_key_experiment_percentage, 10)`
# console: `Feature.enable_percentage_of_
time
(:experiment_key_experiment_percentage, 10)`
#
#
# To disable the experiment:
# To disable the experiment:
#
#
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
# console: `Feature.get(:experiment_key_experiment_percentage).percentage_of_time_value`
# console: `Feature.get(:experiment_key_experiment_percentage).percentage_of_time_value`
#
#
# TODO:
rewrite that
# TODO:
see https://gitlab.com/gitlab-org/gitlab/-/issues/217490
module
Gitlab
module
Gitlab
module
Experimentation
module
Experimentation
EXPERIMENTS
=
{
EXPERIMENTS
=
{
...
...
vendor/project_templates/learn_gitlab.tar.gz
0 → 100644
View file @
9adf18c2
File added
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment