summaryrefslogtreecommitdiff
path: root/app/controllers/admin/hooks_controller.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2017-05-25 19:26:55 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2017-05-25 19:26:55 +0300
commit10a914fbf31b465ac2190730b826f7752ece7da4 (patch)
tree1c02aa995de8ed24bce41d6fcd461c7f92a8f83c /app/controllers/admin/hooks_controller.rb
parent5d5b97cdd692802fc38a12d958a67d73686b97ab (diff)
parentd70f7f5d25aa8753ee3fa26a7564b7d379e72c2d (diff)
downloadgitlab-ce-dz-codeclimate-compare.tar.gz
Merge remote-tracking branch 'origin/master' into dz-codeclimate-comparedz-codeclimate-compare
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/controllers/admin/hooks_controller.rb')
-rw-r--r--app/controllers/admin/hooks_controller.rb32
1 files changed, 22 insertions, 10 deletions
diff --git a/app/controllers/admin/hooks_controller.rb b/app/controllers/admin/hooks_controller.rb
index ccfe553c89e..b9251e140f8 100644
--- a/app/controllers/admin/hooks_controller.rb
+++ b/app/controllers/admin/hooks_controller.rb
@@ -1,5 +1,7 @@
class Admin::HooksController < Admin::ApplicationController
- before_action :hook, only: :edit
+ include HooksExecution
+
+ before_action :hook_logs, only: :edit
def index
@hooks = SystemHook.all
@@ -36,15 +38,9 @@ class Admin::HooksController < Admin::ApplicationController
end
def test
- data = {
- event_name: "project_create",
- name: "Ruby",
- path: "ruby",
- project_id: 1,
- owner_name: "Someone",
- owner_email: "example@gitlabhq.com"
- }
- hook.execute(data, 'system_hooks')
+ status, message = hook.execute(sample_hook_data, 'system_hooks')
+
+ set_hook_execution_notice(status, message)
redirect_back_or_default
end
@@ -55,6 +51,11 @@ class Admin::HooksController < Admin::ApplicationController
@hook ||= SystemHook.find(params[:id])
end
+ def hook_logs
+ @hook_logs ||=
+ Kaminari.paginate_array(hook.web_hook_logs.order(created_at: :desc)).page(params[:page])
+ end
+
def hook_params
params.require(:hook).permit(
:enable_ssl_verification,
@@ -65,4 +66,15 @@ class Admin::HooksController < Admin::ApplicationController
:url
)
end
+
+ def sample_hook_data
+ {
+ event_name: "project_create",
+ name: "Ruby",
+ path: "ruby",
+ project_id: 1,
+ owner_name: "Someone",
+ owner_email: "example@gitlabhq.com"
+ }
+ end
end