Commit 3be7fce9 authored by Doug Stull's avatar Doug Stull

Merge branch 'jejacks0n/fix/nested-experiment-exceptions' into 'master'

Nested experiments now simply track the nesting

See merge request gitlab-org/gitlab!76252
parents e02028e2 108ae22a
......@@ -57,6 +57,10 @@ class ApplicationExperiment < Gitlab::Experiment # rubocop:disable Gitlab/Namesp
Digest::MD5.hexdigest(ingredients.join('|'))
end
def nest_experiment(other)
instance_exec(:nested, { label: other.name }, &Configuration.tracking_behavior)
end
private
def feature_flag_name
......
......@@ -306,6 +306,26 @@ RSpec.describe ApplicationExperiment, :experiment do
end
end
context "when nesting experiments" do
before do
stub_experiments(top: :control, nested: :control)
end
it "doesn't raise an exception" do
expect { experiment(:top) { |e| e.control { experiment(:nested) { } } } }.not_to raise_error
end
it "tracks an event", :snowplow do
experiment(:top) { |e| e.control { experiment(:nested) { } } }
expect(Gitlab::Tracking).to have_received(:event).with( # rubocop:disable RSpec/ExpectGitlabTracking
'top',
'nested',
hash_including(label: 'nested')
)
end
end
context "when caching" do
let(:cache) { Gitlab::Experiment::Configuration.cache }
......
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