Commit 108ae22a authored by jejacks0n's avatar jejacks0n

Nested experiments now simply track the nesting

- This makes nesting experiments more flexible, but can still surface in
reporting.
parent b8d9fecf
...@@ -57,6 +57,10 @@ class ApplicationExperiment < Gitlab::Experiment # rubocop:disable Gitlab/Namesp ...@@ -57,6 +57,10 @@ class ApplicationExperiment < Gitlab::Experiment # rubocop:disable Gitlab/Namesp
Digest::MD5.hexdigest(ingredients.join('|')) Digest::MD5.hexdigest(ingredients.join('|'))
end end
def nest_experiment(other)
instance_exec(:nested, { label: other.name }, &Configuration.tracking_behavior)
end
private private
def feature_flag_name def feature_flag_name
......
...@@ -306,6 +306,26 @@ RSpec.describe ApplicationExperiment, :experiment do ...@@ -306,6 +306,26 @@ RSpec.describe ApplicationExperiment, :experiment do
end end
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 context "when caching" do
let(:cache) { Gitlab::Experiment::Configuration.cache } 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