Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancisco Javier López <fjlopez@gitlab.com>2019-05-07 14:08:25 +0300
committerJames Lopez <james@gitlab.com>2019-05-07 14:08:25 +0300
commit68e533dc219be27f3485d2335e70aa61a193dabb (patch)
treef26b2a94b515469839f8498e18698f3782187260 /app/models/user.rb
parent0910dfb9d6eb9748b6ca24e10a3382a6515615e5 (diff)
Add improvements to the global search process
Removed the conditions added to Project.with_feature_available_for_user, and moved to the IssuableFinder. Now, we ensure that, in the projects retrieved in the Finder, the user has enough access for the feature.
Diffstat (limited to 'app/models/user.rb')
-rw-r--r--app/models/user.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 43039f3760e..4a1bf5514fe 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -757,11 +757,15 @@ class User < ApplicationRecord
# Typically used in conjunction with projects table to get projects
# a user has been given access to.
+ # The param `related_project_column` is the column to compare to the
+ # project_authorizations. By default is projects.id
#
# Example use:
# `Project.where('EXISTS(?)', user.authorizations_for_projects)`
- def authorizations_for_projects(min_access_level: nil)
- authorizations = project_authorizations.select(1).where('project_authorizations.project_id = projects.id')
+ def authorizations_for_projects(min_access_level: nil, related_project_column: 'projects.id')
+ authorizations = project_authorizations
+ .select(1)
+ .where("project_authorizations.project_id = #{related_project_column}")
return authorizations unless min_access_level.present?