Hooks UI improved, Request tests added

This commit is contained in:
Dmitriy Zaporozhets 2012-04-26 20:43:12 +03:00
parent 7b7547aa00
commit 28cb43135c
10 changed files with 125 additions and 85 deletions

View file

@ -11,11 +11,8 @@ class HooksController < ApplicationController
respond_to :html
def index
@hooks = @project.web_hooks
end
def new
@hook = @project.web_hooks.new
@hooks = @project.web_hooks.all
@hook = WebHook.new
end
def create
@ -23,25 +20,22 @@ class HooksController < ApplicationController
@hook.save
if @hook.valid?
redirect_to project_hook_path(@project, @hook)
redirect_to project_hooks_path(@project)
else
render :new
@hooks = @project.web_hooks.all
render :index
end
end
def test
@hook = @project.web_hooks.find(params[:id])
commits = @project.commits(@project.default_branch, nil, 3)
data = @project.web_hook_data(commits.last.id, commits.first.id, "refs/heads/#{@project.default_branch}", current_user.keys.first.identifier)
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
def show
@hook = @project.web_hooks.find(params[:id])
end
def destroy
@hook = @project.web_hooks.find(params[:id])
@hook.destroy