Class: Admin::HooksController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/admin/hooks_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject


7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/admin/hooks_controller.rb', line 7

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

#destroyObject


18
19
20
21
22
23
# File 'app/controllers/admin/hooks_controller.rb', line 18

def destroy
  @hook = SystemHook.find(params[:id])
  @hook.destroy

  redirect_to admin_hooks_path
end

#hook_paramsObject


41
42
43
44
45
46
47
48
49
# File 'app/controllers/admin/hooks_controller.rb', line 41

def hook_params
  params.require(:hook).permit(
    :enable_ssl_verification,
    :push_events,
    :tag_push_events,
    :token,
    :url
  )
end

#indexObject


2
3
4
5
# File 'app/controllers/admin/hooks_controller.rb', line 2

def index
  @hooks = SystemHook.all
  @hook = SystemHook.new
end

#testObject


26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/admin/hooks_controller.rb', line 26

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: "[email protected]"
  }
  @hook.execute(data, 'system_hooks')

  redirect_back_or_default
end