2014-09-02 18:07:02 +05:30
|
|
|
class Admin::HooksController < Admin::ApplicationController
|
|
|
|
def index
|
|
|
|
@hooks = SystemHook.all
|
|
|
|
@hook = SystemHook.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@hook = SystemHook.new(hook_params)
|
|
|
|
|
|
|
|
if @hook.save
|
|
|
|
redirect_to admin_hooks_path, notice: 'Hook was successfully created.'
|
|
|
|
else
|
|
|
|
@hooks = SystemHook.all
|
|
|
|
render :index
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@hook = SystemHook.find(params[:id])
|
|
|
|
@hook.destroy
|
|
|
|
|
|
|
|
redirect_to admin_hooks_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def test
|
|
|
|
@hook = SystemHook.find(params[:hook_id])
|
|
|
|
data = {
|
|
|
|
event_name: "project_create",
|
|
|
|
name: "Ruby",
|
|
|
|
path: "ruby",
|
|
|
|
project_id: 1,
|
|
|
|
owner_name: "Someone",
|
|
|
|
owner_email: "example@gitlabhq.com"
|
|
|
|
}
|
2015-09-11 14:41:01 +05:30
|
|
|
@hook.execute(data, 'system_hooks')
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2015-10-24 18:46:33 +05:30
|
|
|
redirect_back_or_default
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def hook_params
|
2016-06-02 11:05:42 +05:30
|
|
|
params.require(:hook).permit(
|
|
|
|
:enable_ssl_verification,
|
|
|
|
:push_events,
|
|
|
|
:tag_push_events,
|
|
|
|
:token,
|
|
|
|
:url
|
|
|
|
)
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|