diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 17:22:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 17:22:11 +0300 |
commit | 0c872e02b2c822e3397515ec324051ff540f0cd5 (patch) | |
tree | ce2fb6ce7030e4dad0f4118d21ab6453e5938cdd /app/models/issue_collection.rb | |
parent | f7e05a6853b12f02911494c4b3fe53d9540d74fc (diff) |
Add latest changes from gitlab-org/gitlab@15-7-stable-eev15.7.0-rc42
Diffstat (limited to 'app/models/issue_collection.rb')
-rw-r--r-- | app/models/issue_collection.rb | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/app/models/issue_collection.rb b/app/models/issue_collection.rb deleted file mode 100644 index 05607fc3a08..00000000000 --- a/app/models/issue_collection.rb +++ /dev/null @@ -1,44 +0,0 @@ -# frozen_string_literal: true - -# IssueCollection can be used to reduce a list of issues down to a subset. -# -# IssueCollection is not meant to be some sort of Enumerable, instead it's meant -# to take a list of issues and return a new list of issues based on some -# criteria. For example, given a list of issues you may want to return a list of -# issues that can be read or updated by a given user. -class IssueCollection - attr_reader :collection - - def initialize(collection) - @collection = collection - end - - # Returns all the issues that can be updated by the user. - def updatable_by_user(user) - return collection if user.admin? - - # Given all the issue projects we get a list of projects that the current - # user has at least reporter access to. - projects_with_reporter_access = user - .projects_with_reporter_access_limited_to(project_ids) - .pluck(:id) - - collection.select do |issue| - if projects_with_reporter_access.include?(issue.project_id) - true - elsif issue.is_a?(Issue) - issue.assignee_or_author?(user) - else - false - end - end - end - - alias_method :visible_to, :updatable_by_user - - private - - def project_ids - @project_ids ||= collection.map(&:project_id).uniq - end -end |