From bcd0f3a2f6bd59a9de40f5a9f2829cec3d456207 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 2 Feb 2021 06:09:47 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- spec/experiments/application_experiment_spec.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'spec/experiments') diff --git a/spec/experiments/application_experiment_spec.rb b/spec/experiments/application_experiment_spec.rb index 76fdcd222d1..5c5f563a803 100644 --- a/spec/experiments/application_experiment_spec.rb +++ b/spec/experiments/application_experiment_spec.rb @@ -5,6 +5,14 @@ require 'spec_helper' RSpec.describe ApplicationExperiment, :experiment do subject { described_class.new(:stub) } + let(:feature_definition) { { name: 'stub', type: 'experiment', group: 'group::adoption', default_enabled: false } } + + around do |example| + Feature::Definition.definitions[:stub] = Feature::Definition.new('stub.yml', feature_definition) + example.run + Feature::Definition.definitions.delete(:stub) + end + before do allow(subject).to receive(:enabled?).and_return(true) end @@ -105,6 +113,12 @@ RSpec.describe ApplicationExperiment, :experiment do end describe "variant resolution" do + it "uses the default value as specified in the yaml" do + expect(Feature).to receive(:enabled?).with('stub', subject, type: :experiment, default_enabled: :yaml) + + expect(subject.variant.name).to eq('control') + end + it "returns nil when not rolled out" do stub_feature_flags(stub: false) -- cgit v1.2.3