diff options
Diffstat (limited to 'app/models/project_feature.rb')
-rw-r--r-- | app/models/project_feature.rb | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/app/models/project_feature.rb b/app/models/project_feature.rb index f6e889396c6..aea8abecd74 100644 --- a/app/models/project_feature.rb +++ b/app/models/project_feature.rb @@ -2,6 +2,7 @@ class ProjectFeature < ApplicationRecord include Featurable + extend Gitlab::ConfigHelper # When updating this array, make sure to update rubocop/cop/gitlab/feature_available_usage.rb as well. FEATURES = %i[ @@ -48,12 +49,7 @@ class ProjectFeature < ApplicationRecord end end - before_create :set_container_registry_access_level - - # Default scopes force us to unscope here since a service may need to check - # permissions for a project in pending_delete - # http://stackoverflow.com/questions/1540645/how-to-disable-default-scope-for-a-belongs-to - belongs_to :project, -> { unscope(where: :pending_delete) } + belongs_to :project validates :project, presence: true @@ -80,6 +76,14 @@ class ProjectFeature < ApplicationRecord end end + default_value_for(:container_registry_access_level) do |feature| + if gitlab_config_features.container_registry + ENABLED + else + DISABLED + end + end + def public_pages? return true unless Gitlab.config.pages.access_control @@ -94,15 +98,6 @@ class ProjectFeature < ApplicationRecord private - def set_container_registry_access_level - self.container_registry_access_level = - if project&.read_attribute(:container_registry_enabled) - ENABLED - else - DISABLED - end - end - # Validates builds and merge requests access level # which cannot be higher than repository access level def repository_children_level |