2013-01-20 12:20:50 +01:00
|
|
|
class Admin::HooksController < Admin::ApplicationController
|
2012-07-12 21:10:34 +02:00
|
|
|
def index
|
|
|
|
@hooks = SystemHook.all
|
|
|
|
@hook = SystemHook.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@hook = SystemHook.new(params[:hook])
|
|
|
|
|
2012-07-15 14:29:06 +02:00
|
|
|
if @hook.save
|
|
|
|
redirect_to admin_hooks_path, notice: 'Hook was successfully created.'
|
|
|
|
else
|
|
|
|
@hooks = SystemHook.all
|
2012-09-16 13:44:54 +02:00
|
|
|
render :index
|
2012-07-12 21:10:34 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@hook = SystemHook.find(params[:id])
|
|
|
|
@hook.destroy
|
|
|
|
|
|
|
|
redirect_to admin_hooks_path
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def test
|
2012-07-18 23:24:37 +02: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"
|
|
|
|
}
|
2012-07-12 21:10:34 +02:00
|
|
|
@hook.execute(data)
|
|
|
|
|
|
|
|
redirect_to :back
|
|
|
|
end
|
|
|
|
end
|