Files
gitlabhq/app/controllers/projects/runner_projects_controller.rb
T
Lin Jen-Shin b5c8d58afb Use 409 to indicate that interface might be outdated
Because invalid actions shouldn't be shown on the page.
2016-06-28 19:54:18 +08:00

29 lines
764 B
Ruby

class Projects::RunnerProjectsController < Projects::ApplicationController
before_action :authorize_admin_build!
layout 'project_settings'
def create
@runner = Ci::Runner.find(params[:runner_project][:runner_id])
return head(409) if @runner.is_shared? || @runner.locked?
return head(409) unless current_user.ci_authorized_runners.include?(@runner)
path = runners_path(project)
runner_project = @runner.assign_to(project, current_user)
if runner_project.persisted?
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])
runner_project.destroy
redirect_to runners_path(project)
end
end