Commit 2115836f authored by Rémy Coutable's avatar Rémy Coutable

Introduce a new Namespace#licensed_feature_available? method

This makes clear that this method is checking for licensed features,
for consistency with `Project#licensed_feature_available?`.
I believe in the end, `Namespace#licensed_feature_available?` should
replace `Namespace#feature_available?` since `Namespace` only checks
for licensed features.
Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 671982d6
......@@ -284,8 +284,13 @@ class Namespace < ApplicationRecord
false
end
# Deprecated, use #licensed_feature_available? instead. Remove once Namespace#feature_available? isn't used anymore.
def feature_available?(feature)
licensed_feature_available?(feature)
end
# Overridden in EE::Namespace
def feature_available?(_feature)
def licensed_feature_available?(_feature)
false
end
......
......@@ -2324,6 +2324,11 @@ class Project < ApplicationRecord
.external_authorization_service_default_label
end
# Overridden in EE::Project
def licensed_feature_available?(_feature)
false
end
def licensed_features
[]
end
......
......@@ -146,8 +146,8 @@ module EE
# Checks features (i.e. https://about.gitlab.com/pricing/) availabily
# for a given Namespace plan. This method should consider ancestor groups
# being licensed.
override :feature_available?
def feature_available?(feature)
override :licensed_feature_available?
def licensed_feature_available?(feature)
available_features = strong_memoize(:feature_available) do
Hash.new do |h, f|
h[f] = load_feature_available(f)
......
......@@ -804,6 +804,16 @@ module EE
jira_issue_association_required_to_merge_enabled? && prevent_merge_without_jira_issue
end
def licensed_feature_available?(feature, user = nil)
available_features = strong_memoize(:licensed_feature_available) do
Hash.new do |h, f|
h[f] = load_licensed_feature_available(f)
end
end
available_features[feature]
end
private
def group_hooks
......@@ -819,16 +829,6 @@ module EE
import_state.set_next_execution_to_now
end
def licensed_feature_available?(feature, user = nil)
available_features = strong_memoize(:licensed_feature_available) do
Hash.new do |h, f|
h[f] = load_licensed_feature_available(f)
end
end
available_features[feature]
end
def load_licensed_feature_available(feature)
globally_available = License.feature_available?(feature)
......
......@@ -23,8 +23,13 @@ module Gitlab
parent_id.present? || parent.present?
end
# Deprecated, use #licensed_feature_available? instead. Remove once Namespace#feature_available? isn't used anymore.
def feature_available?(feature)
licensed_feature_available?(feature)
end
# Overridden in EE::Namespace
def feature_available?(_feature)
def licensed_feature_available?(_feature)
false
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