summaryrefslogtreecommitdiff
path: root/app/models/project.rb
diff options
context:
space:
mode:
authorMark Chao <mchao@gitlab.com>2019-11-14 10:50:19 +0800
committerMark Chao <mchao@gitlab.com>2019-11-25 09:06:22 +0800
commit2858452b68380e3434832cc790a2a9c8b566efcd (patch)
tree082ea67e2729f9815e5b22641ec2d69efe51064d /app/models/project.rb
parent03c0e9ba65c400e8e391b24c341cd51b01590fad (diff)
downloadgitlab-ce-2858452b68380e3434832cc790a2a9c8b566efcd.tar.gz
Internalize private project minimum access level
Some feature allows GUEST to access only if project is not private. This method returns access level when targeting private projects.
Diffstat (limited to 'app/models/project.rb')
-rw-r--r--app/models/project.rb12
1 files changed, 5 insertions, 7 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index b804b2b2fdd..6595537324e 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -517,13 +517,11 @@ class Project < ApplicationRecord
# This scope returns projects where user has access to both the project and the feature.
def self.filter_by_feature_visibility(feature, user)
- scope = with_feature_available_for_user(feature, user)
-
- if ProjectFeature.guest_allowed_on_private_project?(feature)
- scope.public_or_visible_to_user(user)
- else
- scope.public_or_visible_to_user(user, Gitlab::Access::REPORTER)
- end
+ with_feature_available_for_user(feature, user)
+ .public_or_visible_to_user(
+ user,
+ ProjectFeature.required_minimum_access_level_for_private_project(feature)
+ )
end
scope :active, -> { joins(:issues, :notes, :merge_requests).order('issues.created_at, notes.created_at, merge_requests.created_at DESC') }