Commit e9346c74 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'move-experiment-env-check-first' into 'master'

Check environment for experiment first

See merge request gitlab-org/gitlab!45818
parents 49ad1718 9e6a528b
......@@ -201,7 +201,7 @@ module Gitlab
return false unless EXPERIMENTS.key?(experiment_key)
experiment = experiment(experiment_key)
experiment.enabled? && experiment.enabled_for_environment?
experiment.enabled_for_environment? && experiment.enabled?
end
def enabled_for_attribute?(experiment_key, attribute)
......
......@@ -442,6 +442,14 @@ RSpec.describe Gitlab::Experimentation, :snowplow do
let(:environment) { ::Gitlab.com? }
it { is_expected.to be_falsey }
it 'ensures the typically less expensive environment is checked before the more expensive call to database for Feature' do
expect_next_instance_of(described_class::Experiment) do |experiment|
expect(experiment).not_to receive(:enabled?)
end
subject
end
end
end
......
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