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-02-23 12:10:45 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-02-23 12:10:45 +0300
commitcd40f83527ac4ed4751b4b7849f0416996589d18 (patch)
tree201a36d826fc98f14ee1a7a1dc806b32f51cac00 /spec/experiments/application_experiment_spec.rb
parentd5f3372f10b9fefc8cf831515152eee7ae908f69 (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.rb31
1 files changed, 25 insertions, 6 deletions
diff --git a/spec/experiments/application_experiment_spec.rb b/spec/experiments/application_experiment_spec.rb
index 501d344e920..3803fa10ab3 100644
--- a/spec/experiments/application_experiment_spec.rb
+++ b/spec/experiments/application_experiment_spec.rb
@@ -191,15 +191,15 @@ RSpec.describe ApplicationExperiment, :experiment do
end
context "when caching" do
- let(:cache) { ApplicationExperiment::Cache.new }
+ let(:cache) { Gitlab::Experiment::Configuration.cache }
before do
+ allow(Gitlab::Experiment::Configuration).to receive(:cache).and_call_original
+
cache.clear(key: subject.name)
subject.use { } # setup the control
subject.try { } # setup the candidate
-
- allow(Gitlab::Experiment::Configuration).to receive(:cache).and_return(cache)
end
it "caches the variant determined by the variant resolver" do
@@ -207,7 +207,7 @@ RSpec.describe ApplicationExperiment, :experiment do
subject.run
- expect(cache.read(subject.cache_key)).to eq('candidate')
+ expect(subject.cache.read).to eq('candidate')
end
it "doesn't cache a variant if we don't explicitly provide one" do
@@ -222,7 +222,7 @@ RSpec.describe ApplicationExperiment, :experiment do
subject.run
- expect(cache.read(subject.cache_key)).to be_nil
+ expect(subject.cache.read).to be_nil
end
it "caches a control variant if we assign it specifically" do
@@ -232,7 +232,26 @@ RSpec.describe ApplicationExperiment, :experiment do
# write code that would specify a different variant.
subject.run(:control)
- expect(cache.read(subject.cache_key)).to eq('control')
+ expect(subject.cache.read).to eq('control')
+ end
+
+ context "arbitrary attributes" do
+ before do
+ subject.cache.store.clear(key: subject.name + '_attrs')
+ end
+
+ it "sets and gets attributes about an experiment" do
+ subject.cache.attr_set(:foo, :bar)
+
+ expect(subject.cache.attr_get(:foo)).to eq('bar')
+ end
+
+ it "increments a value for an experiment" do
+ expect(subject.cache.attr_get(:foo)).to be_nil
+
+ expect(subject.cache.attr_inc(:foo)).to eq(1)
+ expect(subject.cache.attr_inc(:foo)).to eq(2)
+ end
end
end
end