summaryrefslogtreecommitdiff
path: root/app/controllers/ci/web_hooks_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/ci/web_hooks_controller.rb')
-rw-r--r--app/controllers/ci/web_hooks_controller.rb53
1 files changed, 53 insertions, 0 deletions
diff --git a/app/controllers/ci/web_hooks_controller.rb b/app/controllers/ci/web_hooks_controller.rb
new file mode 100644
index 00000000000..eea4842c91c
--- /dev/null
+++ b/app/controllers/ci/web_hooks_controller.rb
@@ -0,0 +1,53 @@
+module Ci
+ class WebHooksController < Ci::ApplicationController
+ before_filter :authenticate_user!
+ before_filter :project
+ before_filter :authorize_access_project!
+ before_filter :authorize_manage_project!
+
+ layout 'ci/project'
+
+ def index
+ @web_hooks = @project.web_hooks
+ @web_hook = Ci::WebHook.new
+ end
+
+ def create
+ @web_hook = @project.web_hooks.new(web_hook_params)
+ @web_hook.save
+
+ if @web_hook.valid?
+ redirect_to ci_project_web_hooks_path(@project)
+ else
+ @web_hooks = @project.web_hooks.select(&:persisted?)
+ render :index
+ end
+ end
+
+ def test
+ Ci::TestHookService.new.execute(hook, current_user)
+
+ redirect_to :back
+ end
+
+ def destroy
+ hook.destroy
+
+ redirect_to ci_project_web_hooks_path(@project)
+ end
+
+ private
+
+ def hook
+ @web_hook ||= @project.web_hooks.find(params[:id])
+ end
+
+ def project
+ @project = Ci::Project.find(params[:project_id])
+ end
+
+ def web_hook_params
+ params.require(:web_hook).permit(:url)
+ end
+ end
+end