Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-01-20 12:16:11 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-01-20 12:16:11 +0300
commitedaa33dee2ff2f7ea3fac488d41558eb5f86d68c (patch)
tree11f143effbfeba52329fb7afbd05e6e2a3790241 /spec/experiments
parentd8a5691316400a0f7ec4f83832698f1988eb27c1 (diff)
Add latest changes from gitlab-org/gitlab@14-7-stable-eev14.7.0-rc42
Diffstat (limited to 'spec/experiments')
-rw-r--r--spec/experiments/change_continuous_onboarding_link_urls_experiment_spec.rb53
-rw-r--r--spec/experiments/new_project_sast_enabled_experiment_spec.rb7
-rw-r--r--spec/experiments/require_verification_for_namespace_creation_experiment_spec.rb59
3 files changed, 65 insertions, 54 deletions
diff --git a/spec/experiments/change_continuous_onboarding_link_urls_experiment_spec.rb b/spec/experiments/change_continuous_onboarding_link_urls_experiment_spec.rb
deleted file mode 100644
index 815aaf7c397..00000000000
--- a/spec/experiments/change_continuous_onboarding_link_urls_experiment_spec.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe ChangeContinuousOnboardingLinkUrlsExperiment, :snowplow do
- before do
- stub_experiments(change_continuous_onboarding_link_urls: 'control')
- end
-
- describe '#track' do
- context 'when no namespace has been set' do
- it 'tracks the action as normal' do
- subject.track(:some_action)
-
- expect_snowplow_event(
- category: subject.name,
- action: 'some_action',
- namespace: nil,
- context: [
- {
- schema: 'iglu:com.gitlab/gitlab_experiment/jsonschema/1-0-0',
- data: an_instance_of(Hash)
- }
- ]
- )
- end
- end
-
- context 'when a namespace has been set' do
- let_it_be(:namespace) { create(:namespace) }
-
- before do
- subject.namespace = namespace
- end
-
- it 'tracks the action and merges the namespace into the event args' do
- subject.track(:some_action)
-
- expect_snowplow_event(
- category: subject.name,
- action: 'some_action',
- namespace: namespace,
- context: [
- {
- schema: 'iglu:com.gitlab/gitlab_experiment/jsonschema/1-0-0',
- data: an_instance_of(Hash)
- }
- ]
- )
- end
- end
- end
-end
diff --git a/spec/experiments/new_project_sast_enabled_experiment_spec.rb b/spec/experiments/new_project_sast_enabled_experiment_spec.rb
index 38f58c01973..041e5dfa469 100644
--- a/spec/experiments/new_project_sast_enabled_experiment_spec.rb
+++ b/spec/experiments/new_project_sast_enabled_experiment_spec.rb
@@ -4,7 +4,12 @@ require 'spec_helper'
RSpec.describe NewProjectSastEnabledExperiment do
it "defines the expected behaviors and variants" do
- expect(subject.behaviors.keys).to match_array(%w[control candidate free_indicator unchecked_candidate])
+ expect(subject.variant_names).to match_array([
+ :candidate,
+ :free_indicator,
+ :unchecked_candidate,
+ :unchecked_free_indicator
+ ])
end
it "publishes to the database" do
diff --git a/spec/experiments/require_verification_for_namespace_creation_experiment_spec.rb b/spec/experiments/require_verification_for_namespace_creation_experiment_spec.rb
new file mode 100644
index 00000000000..87417fe1637
--- /dev/null
+++ b/spec/experiments/require_verification_for_namespace_creation_experiment_spec.rb
@@ -0,0 +1,59 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe RequireVerificationForNamespaceCreationExperiment, :experiment do
+ subject(:experiment) { described_class.new(user: user) }
+
+ let_it_be(:user) { create(:user) }
+
+ describe '#candidate?' do
+ context 'when experiment subject is candidate' do
+ before do
+ stub_experiments(require_verification_for_namespace_creation: :candidate)
+ end
+
+ it 'returns true' do
+ expect(experiment.candidate?).to eq(true)
+ end
+ end
+
+ context 'when experiment subject is control' do
+ before do
+ stub_experiments(require_verification_for_namespace_creation: :control)
+ end
+
+ it 'returns false' do
+ expect(experiment.candidate?).to eq(false)
+ end
+ end
+ end
+
+ describe '#record_conversion' do
+ let_it_be(:namespace) { create(:namespace) }
+
+ context 'when should_track? is false' do
+ before do
+ allow(experiment).to receive(:should_track?).and_return(false)
+ end
+
+ it 'does not record a conversion event' do
+ expect(experiment.publish_to_database).to be_nil
+ expect(experiment.record_conversion(namespace)).to be_nil
+ end
+ end
+
+ context 'when should_track? is true' do
+ before do
+ allow(experiment).to receive(:should_track?).and_return(true)
+ end
+
+ it 'records a conversion event' do
+ experiment_subject = experiment.publish_to_database
+
+ expect { experiment.record_conversion(namespace) }.to change { experiment_subject.reload.converted_at }.from(nil)
+ .and change { experiment_subject.context }.to include('namespace_id' => namespace.id)
+ end
+ end
+ end
+end