summaryrefslogtreecommitdiff
path: root/spec/helpers/learn_gitlab_helper_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/helpers/learn_gitlab_helper_spec.rb')
-rw-r--r--spec/helpers/learn_gitlab_helper_spec.rb66
1 files changed, 59 insertions, 7 deletions
diff --git a/spec/helpers/learn_gitlab_helper_spec.rb b/spec/helpers/learn_gitlab_helper_spec.rb
index 82c8e4ba596..cf0d329c36f 100644
--- a/spec/helpers/learn_gitlab_helper_spec.rb
+++ b/spec/helpers/learn_gitlab_helper_spec.rb
@@ -7,14 +7,14 @@ RSpec.describe LearnGitlabHelper do
include Devise::Test::ControllerHelpers
let_it_be(:user) { create(:user) }
- let_it_be(:project) { create(:project, name: LearnGitlab::PROJECT_NAME, namespace: user.namespace) }
+ let_it_be(:project) { create(:project, name: LearnGitlab::Project::PROJECT_NAME, namespace: user.namespace) }
let_it_be(:namespace) { project.namespace }
before do
project.add_developer(user)
allow(helper).to receive(:user).and_return(user)
- allow_next_instance_of(LearnGitlab) do |learn_gitlab|
+ allow_next_instance_of(LearnGitlab::Project) do |learn_gitlab|
allow(learn_gitlab).to receive(:project).and_return(project)
end
@@ -41,12 +41,12 @@ RSpec.describe LearnGitlabHelper do
it 'sets correct path and completion status' do
expect(onboarding_actions_data[:git_write]).to eq({
- url: project_issue_url(project, LearnGitlabHelper::ACTION_ISSUE_IDS[:git_write]),
+ url: project_issue_url(project, LearnGitlab::Onboarding::ACTION_ISSUE_IDS[:git_write]),
completed: true,
svg: helper.image_path("learn_gitlab/git_write.svg")
})
expect(onboarding_actions_data[:pipeline_created]).to eq({
- url: project_issue_url(project, LearnGitlabHelper::ACTION_ISSUE_IDS[:pipeline_created]),
+ url: project_issue_url(project, LearnGitlab::Onboarding::ACTION_ISSUE_IDS[:pipeline_created]),
completed: false,
svg: helper.image_path("learn_gitlab/pipeline_created.svg")
})
@@ -75,7 +75,7 @@ RSpec.describe LearnGitlabHelper do
before do
stub_experiment_for_subject(learn_gitlab_a: experiment_a, learn_gitlab_b: experiment_b)
allow(OnboardingProgress).to receive(:onboarding?).with(project.namespace).and_return(onboarding)
- allow_next(LearnGitlab, user).to receive(:available?).and_return(learn_gitlab_available)
+ allow_next(LearnGitlab::Project, user).to receive(:available?).and_return(learn_gitlab_available)
end
context 'when signed in' do
@@ -85,10 +85,62 @@ RSpec.describe LearnGitlabHelper do
it { is_expected.to eq(result) }
end
+ end
- context 'when not signed in' do
- it { is_expected.to eq(false) }
+ context 'when not signed in' do
+ before do
+ stub_experiment_for_subject(learn_gitlab_a: true, learn_gitlab_b: true)
end
+
+ it { is_expected.to eq(false) }
+ end
+ end
+
+ describe '.onboarding_sections_data' do
+ subject(:sections) { helper.onboarding_sections_data }
+
+ it 'has the right keys' do
+ expect(sections.keys).to contain_exactly(:deploy, :plan, :workspace)
+ end
+ it 'has the svg' do
+ expect(sections.values.map { |section| section.keys }).to eq([[:svg]] * 3)
+ end
+ end
+
+ describe '.learn_gitlab_experiment_tracking_category' do
+ using RSpec::Parameterized::TableSyntax
+
+ let_it_be(:user) { create(:user) }
+
+ subject { helper.learn_gitlab_experiment_tracking_category }
+
+ where(:experiment_a, :experiment_b, :result) do
+ false | false | nil
+ false | true | 'Growth::Activation::Experiment::LearnGitLabB'
+ true | false | 'Growth::Conversion::Experiment::LearnGitLabA'
+ true | true | 'Growth::Conversion::Experiment::LearnGitLabA'
+ end
+
+ with_them do
+ before do
+ stub_experiment_for_subject(learn_gitlab_a: experiment_a, learn_gitlab_b: experiment_b)
+ end
+
+ context 'when signed in' do
+ before do
+ sign_in(user)
+ end
+
+ it { is_expected.to eq(result) }
+ end
+ end
+
+ context 'when not signed in' do
+ before do
+ stub_experiment_for_subject(learn_gitlab_a: true, learn_gitlab_b: true)
+ end
+
+ it { is_expected.to eq(nil) }
end
end
end