Commit 15a7997f authored by Nicolas Dular's avatar Nicolas Dular

Use learn gitlab utlimate template for experiment

In the learn gitlab experiment we want to link to issues that are only
available in the learn-gitlab-ultimate project template, since the
actions require a trial.
With this MR, we use the ultimate template when the experiment is active
and also update the issue IDs to link to the right issue to get more
information.
parent 615be423
......@@ -24,13 +24,13 @@ module LearnGitlabHelper
private
ACTION_ISSUE_IDS = {
git_write: 2,
pipeline_created: 4,
merge_request_created: 5,
user_added: 7,
trial_started: 13,
required_mr_approvals_enabled: 15,
code_owners_enabled: 16
git_write: 6,
pipeline_created: 7,
merge_request_created: 9,
user_added: 8,
trial_started: 2,
required_mr_approvals_enabled: 11,
code_owners_enabled: 10
}.freeze
ACTION_DOC_URLS = {
......
......@@ -4,6 +4,9 @@ module Registrations
class ProjectsController < ApplicationController
layout 'checkout'
LEARN_GITLAB_TEMPLATE = 'learn_gitlab.tar.gz'
LEARN_GITLAB_ULTIMATE_TEMPLATE = 'learn_gitlab_ultimate_trial.tar.gz'
before_action :check_signup_onboarding_enabled
before_action only: [:new] do
set_namespace
......@@ -48,20 +51,12 @@ module Registrations
end
def create_learn_gitlab_project
title, filename = if helpers.in_trial_onboarding_flow?
[s_('Learn GitLab - Ultimate trial'), 'learn_gitlab_ultimate_trial.tar.gz']
else
[s_('Learn GitLab'), 'learn_gitlab.tar.gz']
end
learn_gitlab_template_path = Rails.root.join('vendor', 'project_templates', filename)
learn_gitlab_project = File.open(learn_gitlab_template_path) do |archive|
::Projects::GitlabProjectsImportService.new(
current_user,
namespace_id: @project.namespace_id,
file: archive,
name: title
name: learn_gitlab_project_name
).execute
end
......@@ -88,5 +83,24 @@ module Registrations
:visibility_level
]
end
def learn_gitlab_project_name
helpers.in_trial_onboarding_flow? ? s_('Learn GitLab - Ultimate trial') : s_('Learn GitLab')
end
def learn_gitlab_template_path
file = if helpers.in_trial_onboarding_flow? || learn_gitlab_experiment_enabled?
LEARN_GITLAB_ULTIMATE_TEMPLATE
else
LEARN_GITLAB_TEMPLATE
end
Rails.root.join('vendor', 'project_templates', file)
end
def learn_gitlab_experiment_enabled?
Gitlab::Experimentation.in_experiment_group?(:learn_gitlab_a, subject: current_user) ||
Gitlab::Experimentation.in_experiment_group?(:learn_gitlab_b, subject: current_user)
end
end
end
......@@ -3,8 +3,11 @@
require 'spec_helper'
RSpec.describe Registrations::ProjectsController do
include AfterNextHelpers
let_it_be(:user) { create(:user) }
let_it_be(:namespace) { create(:group) }
let_it_be(:project) { create(:project) }
describe 'GET #new' do
subject { get :new }
......@@ -76,10 +79,40 @@ RSpec.describe Registrations::ProjectsController do
expect(namespace.projects.find_by_name(s_('Learn GitLab'))).to be_import_finished
end
context 'learn gitlab project' do
using RSpec::Parameterized::TableSyntax
where(:trial, :experiment_enabled, :project_name, :template) do
false | false | 'Learn GitLab' | described_class::LEARN_GITLAB_TEMPLATE
false | true | 'Learn GitLab' | described_class::LEARN_GITLAB_ULTIMATE_TEMPLATE
true | false | 'Learn GitLab - Ultimate trial' | described_class::LEARN_GITLAB_ULTIMATE_TEMPLATE
true | true | 'Learn GitLab - Ultimate trial' | described_class::LEARN_GITLAB_ULTIMATE_TEMPLATE
end
with_them do
let(:path) { Rails.root.join('vendor', 'project_templates', template) }
let(:expected_arguments) { { namespace_id: namespace.id, file: handle, name: project_name } }
let(:handle) { double }
let(:trial_onboarding_flow_params) { { trial_onboarding_flow: trial } }
before do
stub_experiment_for_subject(learn_gitlab_a: experiment_enabled)
allow(File).to receive(:open).and_call_original
expect(File).to receive(:open).with(path).and_yield(handle)
end
specify do
expect_next(::Projects::GitlabProjectsImportService, user, expected_arguments)
.to receive(:execute).and_return(project)
subject
end
end
end
context 'when the trial onboarding is active' do
let_it_be(:trial_onboarding_flow_params) { { trial_onboarding_flow: true } }
let_it_be(:trial_onboarding_issues_enabled) { true }
let_it_be(:project) { create(:project) }
let_it_be(:first_project) { create(:project) }
let_it_be(:trial_onboarding_context) do
{ learn_gitlab_project_id: project.id, namespace_id: project.namespace_id, project_id: first_project.id }
......
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