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>2021-01-27 00:09:04 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-01-27 00:09:04 +0300
commitdafbc31897e3751b6a4b34a7e32e1ecf5bfd4657 (patch)
treee454cd0c43ad4e73980cd0adb906a663faa07965 /spec/experiments/application_experiment_spec.rb
parent25eb713a7fdb787a67d74a88a89433839aab5642 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/experiments/application_experiment_spec.rb')
-rw-r--r--spec/experiments/application_experiment_spec.rb42
1 files changed, 39 insertions, 3 deletions
diff --git a/spec/experiments/application_experiment_spec.rb b/spec/experiments/application_experiment_spec.rb
index ece52d37351..beefc09e591 100644
--- a/spec/experiments/application_experiment_spec.rb
+++ b/spec/experiments/application_experiment_spec.rb
@@ -2,9 +2,45 @@
require 'spec_helper'
-RSpec.describe ApplicationExperiment do
+RSpec.describe ApplicationExperiment, :experiment do
subject { described_class.new(:stub) }
+ before do
+ allow(subject).to receive(:enabled?).and_return(true)
+ end
+
+ describe "enabled" do
+ before do
+ allow(subject).to receive(:enabled?).and_call_original
+
+ allow(Feature::Definition).to receive(:get).and_return('_instance_')
+ allow(Gitlab).to receive(:dev_env_or_com?).and_return(true)
+ allow(Feature).to receive(:get).and_return(double(state: :on))
+ end
+
+ it "is enabled when all criteria are met" do
+ expect(subject).to be_enabled
+ end
+
+ it "isn't enabled if the feature definition doesn't exist" do
+ expect(Feature::Definition).to receive(:get).with('stub').and_return(nil)
+
+ expect(subject).not_to be_enabled
+ end
+
+ it "isn't enabled if we're not in dev or dotcom environments" do
+ expect(Gitlab).to receive(:dev_env_or_com?).and_return(false)
+
+ expect(subject).not_to be_enabled
+ end
+
+ it "isn't enabled if the feature flag state is :off" do
+ expect(Feature).to receive(:get).with('stub').and_return(double(state: :off))
+
+ expect(subject).not_to be_enabled
+ end
+ end
+
describe "publishing results" do
it "tracks the assignment" do
expect(subject).to receive(:track).with(:assignment)
@@ -31,8 +67,8 @@ RSpec.describe ApplicationExperiment do
end
describe "tracking events", :snowplow do
- it "doesn't track if excluded" do
- subject.exclude { true }
+ it "doesn't track if we shouldn't track" do
+ allow(subject).to receive(:should_track?).and_return(false)
subject.track(:action)