gitlab-org--gitlab-foss/app/controllers/projects/runner_projects_controller.rb

28 lines
706 B
Ruby
Raw Normal View History

2015-12-04 11:55:23 +00:00
class Projects::RunnerProjectsController < Projects::ApplicationController
before_action :authorize_admin_build!
2015-12-04 11:55:23 +00:00
layout 'project_settings'
def create
@runner = Ci::Runner.find(params[:runner_project][:runner_id])
return head(403) unless can?(current_user, :assign_runner, @runner)
2015-12-04 11:55:23 +00:00
path = runners_path(project)
runner_project = @runner.assign_to(project, current_user)
2015-12-04 11:55:23 +00:00
if runner_project.persisted?
2015-12-04 11:55:23 +00:00
redirect_to path
else
redirect_to path, alert: 'Failed adding runner to project'
end
end
def destroy
runner_project = project.runner_projects.find(params[:id])
2015-12-04 11:55:23 +00:00
runner_project.destroy
redirect_to runners_path(project), status: 302
2015-12-04 11:55:23 +00:00
end
end