System Hooks: CRUD has done
This commit is contained in:
parent
65dc68b35c
commit
c38578428b
9 changed files with 141 additions and 77 deletions
39
app/controllers/admin/hooks_controller.rb
Normal file
39
app/controllers/admin/hooks_controller.rb
Normal file
|
@ -0,0 +1,39 @@
|
|||
class Admin::HooksController < ApplicationController
|
||||
layout "admin"
|
||||
before_filter :authenticate_user!
|
||||
before_filter :authenticate_admin!
|
||||
|
||||
def index
|
||||
@hooks = SystemHook.all
|
||||
@hook = SystemHook.new
|
||||
end
|
||||
|
||||
def create
|
||||
@hook = SystemHook.new(params[:hook])
|
||||
|
||||
respond_to do |format|
|
||||
if @hook.save
|
||||
format.html { redirect_to admin_hooks_path, notice: 'Hook was successfully created.' }
|
||||
else
|
||||
format.html { render :index }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@hook = SystemHook.find(params[:id])
|
||||
@hook.destroy
|
||||
|
||||
redirect_to admin_hooks_path
|
||||
end
|
||||
|
||||
|
||||
def test
|
||||
@hook = @project.hooks.find(params[:id])
|
||||
commits = @project.commits(@project.default_branch, nil, 3)
|
||||
data = @project.post_receive_data(commits.last.id, commits.first.id, "refs/heads/#{@project.default_branch}", current_user)
|
||||
@hook.execute(data)
|
||||
|
||||
redirect_to :back
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue