summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTomasz Maczukin <tomasz@maczukin.pl>2016-02-10 12:26:56 +0100
committerTomasz Maczukin <tomasz@maczukin.pl>2016-02-19 13:18:48 +0100
commit24eed1c5c1cbbad7081625ad98d06d151933f583 (patch)
tree271efe36978ae032409c7e6b63f434201adbd400 /lib
parent36e7ffea5de84102a7306faf679cdb5b81920f19 (diff)
downloadgitlab-ce-24eed1c5c1cbbad7081625ad98d06d151933f583.tar.gz
Modify runner projects selecting method in runners API
Diffstat (limited to 'lib')
-rw-r--r--lib/api/entities.rb6
-rw-r--r--lib/api/runners.rb6
2 files changed, 4 insertions, 8 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index a8c00542d35..3f1594994c9 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -387,12 +387,12 @@ module API
expose :tag_list
expose :version, :revision, :platform, :architecture
expose :contacted_at, as: :last_contact
- expose :token, if: lambda { |runner, options| options[:user_is_admin] || !runner.is_shared? }
+ expose :token, if: lambda { |runner, options| options[:current_user].is_admin? || !runner.is_shared? }
expose :projects, with: Entities::RunnerProjectDetails do |runner, options|
- if options[:user_is_admin]
+ if options[:current_user].is_admin?
runner.projects
else
- runner.projects.where(id: options[:available_projects_ids])
+ options[:current_user].authorized_projects.where(id: runner.projects)
end
end
end
diff --git a/lib/api/runners.rb b/lib/api/runners.rb
index e807d2eccf0..03803ede9fc 100644
--- a/lib/api/runners.rb
+++ b/lib/api/runners.rb
@@ -33,11 +33,7 @@ module API
runner = get_runner(params[:id])
authenticate_show_runner!(runner)
- available_projects_ids = runner.projects.select{ |p| can?(current_user, :read_project, p) }
- .map(&:id) unless current_user.is_admin?
-
- present runner, with: Entities::RunnerDetails, user_is_admin: current_user.is_admin?,
- available_projects_ids: available_projects_ids
+ present runner, with: Entities::RunnerDetails, current_user: current_user
end
# Update runner's details