blob: 4359e99668f277348a854d9ba3a4d0ae0b5080f8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
class HooksController < ApplicationController
before_filter :project
layout "project"
# Authorize
before_filter :add_project_abilities
before_filter :authorize_read_project!
before_filter :authorize_admin_project!, only: [:new, :create, :destroy]
respond_to :html
def index
@hooks = @project.hooks.all
@hook = ProjectHook.new
end
def create
@hook = @project.hooks.new(params[:hook])
@hook.save
if @hook.valid?
redirect_to project_hooks_path(@project)
else
@hooks = @project.hooks.all
render :index
end
end
def test
TestHookContext.new(project, current_user, params).execute
redirect_to :back
end
def destroy
@hook = @project.hooks.find(params[:id])
@hook.destroy
redirect_to project_hooks_path(@project)
end
end
|