gitlab-org--gitlab-foss/app/controllers/admin/hooks_controller.rb

45 lines
918 B
Ruby
Raw Normal View History

class Admin::HooksController < Admin::ApplicationController
2012-07-12 19:10:34 +00:00
def index
@hooks = SystemHook.all
@hook = SystemHook.new
end
def create
@hook = SystemHook.new(hook_params)
2012-07-12 19:10:34 +00:00
2012-07-15 12:29:06 +00:00
if @hook.save
redirect_to admin_hooks_path, notice: 'Hook was successfully created.'
else
@hooks = SystemHook.all
render :index
2012-07-12 19:10:34 +00:00
end
end
def destroy
@hook = SystemHook.find(params[:id])
@hook.destroy
redirect_to admin_hooks_path
end
def test
2012-07-18 21:24:37 +00:00
@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"
}
@hook.execute(data, 'system_hooks')
2012-07-12 19:10:34 +00:00
redirect_back_or_default
2012-07-12 19:10:34 +00:00
end
def hook_params
params.require(:hook).permit(:url, :enable_ssl_verification, :push_events, :tag_push_events)
end
2012-07-12 19:10:34 +00:00
end