summaryrefslogtreecommitdiff
path: root/app/controllers/ci/runner_projects_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/ci/runner_projects_controller.rb')
-rw-r--r--app/controllers/ci/runner_projects_controller.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/app/controllers/ci/runner_projects_controller.rb b/app/controllers/ci/runner_projects_controller.rb
new file mode 100644
index 00000000000..3a52087cc6b
--- /dev/null
+++ b/app/controllers/ci/runner_projects_controller.rb
@@ -0,0 +1,34 @@
+module Ci
+ class RunnerProjectsController < Ci::ApplicationController
+ before_filter :authenticate_user!
+ before_filter :project
+ before_filter :authorize_manage_project!
+
+ layout 'ci/project'
+
+ def create
+ @runner = Ci::Runner.find(params[:runner_project][:runner_id])
+
+ return head(403) unless current_user.authorized_runners.include?(@runner)
+
+ if @runner.assign_to(project, current_user)
+ redirect_to ci_project_runners_path(project)
+ else
+ redirect_to ci_project_runners_path(project), alert: 'Failed adding runner to project'
+ end
+ end
+
+ def destroy
+ runner_project = project.runner_projects.find(params[:id])
+ runner_project.destroy
+
+ redirect_to ci_project_runners_path(project)
+ end
+
+ private
+
+ def project
+ @project ||= Ci::Project.find(params[:project_id])
+ end
+ end
+end