Commit c996b5e3 authored by Robert Speicher's avatar Robert Speicher

Feature flag check in Namespace#feature_available?

parent c81d2244
...@@ -72,6 +72,9 @@ module EE ...@@ -72,6 +72,9 @@ module EE
# for a given Namespace plan. This method should consider ancestor groups # for a given Namespace plan. This method should consider ancestor groups
# being licensed. # being licensed.
def feature_available?(feature) def feature_available?(feature)
# This feature might not be behind a feature flag at all, so default to true
return false unless ::Feature.enabled?(feature, default_enabled: true)
available_features = strong_memoize(:feature_available) do available_features = strong_memoize(:feature_available) do
Hash.new do |h, feature| Hash.new do |h, feature|
h[feature] = load_feature_available(feature) h[feature] = load_feature_available(feature)
......
...@@ -218,6 +218,22 @@ describe Namespace do ...@@ -218,6 +218,22 @@ describe Namespace do
is_expected.to be_falsy is_expected.to be_falsy
end end
end end
context 'when feature is disabled by a feature flag' do
it 'returns false' do
stub_feature_flags(feature => false)
is_expected.to eq(false)
end
end
context 'when feature is enabled by a feature flag' do
it 'returns true' do
stub_feature_flags(feature => true)
is_expected.to eq(true)
end
end
end end
describe '#max_active_pipelines' do describe '#max_active_pipelines' do
......
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