Files
gitlabhq/app/controllers/admin/runner_projects_controller.rb
Rémy CoutableandRobert Speicher 2a7ea34173 Merge branch 'enable-shared-runners-with-admins' into 'master'
Admin should be able to turn shared runners into specific ones:

## What does this MR do?

Make sure admins could turn shared runners into specific runners.

## Are there points in the code the reviewer needs to double check?

Is this the desired behaviour?

## Why was this MR needed?

Closes #19039
Closes #19272

![Screen_Shot_2016-06-30_at_9.30.05_PM](/uploads/97eb3b4923fd4e498b1f8ca70b1345c8/Screen_Shot_2016-06-30_at_9.30.05_PM.png)

See merge request !4961
(cherry picked from commit b569f842b3)
2016-07-06 12:39:03 -04:00

33 lines
770 B
Ruby

class Admin::RunnerProjectsController < Admin::ApplicationController
before_action :project, only: [:create]
def create
@runner = Ci::Runner.find(params[:runner_project][:runner_id])
runner_project = @runner.assign_to(@project, current_user)
if runner_project.persisted?
redirect_to admin_runner_path(@runner)
else
redirect_to admin_runner_path(@runner), alert: 'Failed adding runner to project'
end
end
def destroy
rp = Ci::RunnerProject.find(params[:id])
runner = rp.runner
rp.destroy
redirect_to admin_runner_path(runner)
end
private
def project
@project = Project.find_with_namespace(
[params[:namespace_id], '/', params[:project_id]].join('')
)
@project || render_404
end
end