Reuse query from ProjectsFinder to get projects accessible to current user.

This commit is contained in:
Rubén Dávila 2016-03-01 11:45:30 -05:00
parent 90ced487f2
commit 0e1d440805
1 changed files with 1 additions and 3 deletions

View File

@ -7,9 +7,7 @@ class Projects::ForksController < Projects::ApplicationController
base_query = project.forks.includes(:creator)
@forks = if current_user
base_query.where('projects.visibility_level IN (?) OR projects.id IN (?)',
Project.public_and_internal_levels,
current_user.authorized_projects.pluck(:id))
base_query.merge(ProjectsFinder.new.execute(current_user))
else
base_query.where('projects.visibility_level = ?', Project::PUBLIC)
end