Commit 3cc9e16a authored by Sean McGivern's avatar Sean McGivern

Merge branch 'onboarding-experiment-set-cookie' into 'master'

Set a cookie when creating Learn Gitlab project

See merge request gitlab-org/gitlab!34051
parents b594447f cc30d5d0
...@@ -25,9 +25,16 @@ module Registrations ...@@ -25,9 +25,16 @@ module Registrations
private private
def create_learn_gitlab_project def create_learn_gitlab_project
File.open(learn_gitlab_template_path) do |archive| 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 ::Projects::GitlabProjectsImportService.new(
current_user,
namespace_id: @project.namespace_id,
file: archive,
name: s_('Learn GitLab')
).execute
end end
cookies[:onboarding_issues_settings] = { 'groups#show' => true, 'projects#show' => true, 'issues#index' => true }.to_json if learn_gitlab_project.saved?
end end
def learn_gitlab_template_path def learn_gitlab_template_path
......
...@@ -64,7 +64,7 @@ RSpec.describe Registrations::ProjectsController do ...@@ -64,7 +64,7 @@ RSpec.describe Registrations::ProjectsController do
stub_experiment_for_user(onboarding_issues: true) stub_experiment_for_user(onboarding_issues: true)
end end
it 'creates a new project, a "Learn GitLab" project and redirects to the experience level page' do it 'creates a new project, a "Learn GitLab" project, sets a cookie and redirects to the experience level page' do
expect { subject }.to change { namespace.projects.pluck(:name) }.from([]).to(['New project', s_('Learn GitLab')]) expect { subject }.to change { namespace.projects.pluck(:name) }.from([]).to(['New project', s_('Learn GitLab')])
Sidekiq::Worker.drain_all Sidekiq::Worker.drain_all
...@@ -72,6 +72,7 @@ RSpec.describe Registrations::ProjectsController do ...@@ -72,6 +72,7 @@ RSpec.describe Registrations::ProjectsController do
expect(subject).to have_gitlab_http_status(:redirect) expect(subject).to have_gitlab_http_status(:redirect)
expect(subject).to redirect_to(users_sign_up_experience_level_path) expect(subject).to redirect_to(users_sign_up_experience_level_path)
expect(namespace.projects.find_by_name(s_('Learn GitLab'))).to be_import_finished expect(namespace.projects.find_by_name(s_('Learn GitLab'))).to be_import_finished
expect(cookies[:onboarding_issues_settings]).not_to be_nil
end end
context 'when the project cannot be saved' do context 'when the project cannot be saved' 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