Commit 70417307 authored by Robert Speicher's avatar Robert Speicher Committed by Douglas Barbosa Alexandre

Additional feature flag check for EE::Project

parent ecb6c46c
......@@ -266,7 +266,7 @@ module EE
if ProjectFeature::FEATURES.include?(feature)
super
else
licensed_feature_available?(feature)
licensed_feature_available?(feature, user)
end
end
......@@ -578,7 +578,10 @@ module EE
import_state.set_next_execution_to_now
end
def licensed_feature_available?(feature)
def licensed_feature_available?(feature, user = nil)
# This feature might not be behind a feature flag at all, so default to true
return false unless ::Feature.enabled?(feature, user, default_enabled: true)
available_features = strong_memoize(:licensed_feature_available) do
Hash.new do |h, feature|
h[feature] = load_licensed_feature_available(feature)
......
......@@ -347,6 +347,14 @@ describe Project do
it 'returns true' do
is_expected.to eq(true)
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
end
context 'not allowed by Plan License but project and namespace are public' 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