diff --git a/app/models/namespace.rb b/app/models/namespace.rb index 7b7c2ea9d7bdd7e4cd65f082b7202cb05105f8a4..0e47326b028750650275faef3dc955b1bc8a3ad0 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -284,8 +284,13 @@ def multiple_issue_boards_available? 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 diff --git a/app/models/project.rb b/app/models/project.rb index 61f165b9daa6bb272d0144529c1e93e6d25e9d65..b21d98189534485f9a36d25f8e576bfb43109fa6 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -2324,6 +2324,11 @@ def external_authorization_classification_label .external_authorization_service_default_label end + # Overridden in EE::Project + def licensed_feature_available?(_feature) + false + end + def licensed_features [] end diff --git a/ee/app/models/ee/namespace.rb b/ee/app/models/ee/namespace.rb index e4dbdad3eeab0883a52ea8dc32f06ab386403351..0789a30735552670a97916978e1403f94f2397d9 100644 --- a/ee/app/models/ee/namespace.rb +++ b/ee/app/models/ee/namespace.rb @@ -146,8 +146,8 @@ def old_path_with_namespace_for(project) # 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) diff --git a/ee/app/models/ee/project.rb b/ee/app/models/ee/project.rb index abdc9f33752b1e7c733258dbc3c22b64eb900f19..f1b43f28bfed5da4c764ee36e7630b1535d2a4a3 100644 --- a/ee/app/models/ee/project.rb +++ b/ee/app/models/ee/project.rb @@ -804,6 +804,16 @@ def prevent_merge_without_jira_issue? 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 @@ def set_next_execution_timestamp_to_now 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) diff --git a/lib/gitlab/background_migration/user_mentions/models/namespace.rb b/lib/gitlab/background_migration/user_mentions/models/namespace.rb index 6587417d048ddf7eb66a830cdaf7128ae07f8f6e..a2b50c41f4a2da1d817113ef3c1155ebccaeacf1 100644 --- a/lib/gitlab/background_migration/user_mentions/models/namespace.rb +++ b/lib/gitlab/background_migration/user_mentions/models/namespace.rb @@ -23,8 +23,13 @@ def has_parent? 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