diff options
| author | Valeriy Sizov <vsv2711@gmail.com> | 2012-07-12 15:36:33 +0300 |
|---|---|---|
| committer | Valeriy Sizov <vsv2711@gmail.com> | 2012-07-19 00:25:10 +0300 |
| commit | 65dc68b35c0ad455336abf33def5d920166f7c83 (patch) | |
| tree | 3ae9e0bc323e2bf6fca193b88597fe496c755f2b /app | |
| parent | 72a571724d84d112f98a5543c971e9b3b9da1383 (diff) | |
| download | gitlab-ce-65dc68b35c0ad455336abf33def5d920166f7c83.tar.gz | |
Refactoring of hook functionality & bootsrap system hooks
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/hooks_controller.rb | 12 | ||||
| -rw-r--r-- | app/models/project.rb | 2 | ||||
| -rw-r--r-- | app/models/project_hook.rb | 3 | ||||
| -rw-r--r-- | app/models/system_hook.rb | 3 | ||||
| -rw-r--r-- | app/models/web_hook.rb | 2 | ||||
| -rw-r--r-- | app/roles/git_push.rb | 2 |
6 files changed, 14 insertions, 10 deletions
diff --git a/app/controllers/hooks_controller.rb b/app/controllers/hooks_controller.rb index 9627aba9771..ad2fb3ae781 100644 --- a/app/controllers/hooks_controller.rb +++ b/app/controllers/hooks_controller.rb @@ -11,24 +11,24 @@ class HooksController < ApplicationController respond_to :html def index - @hooks = @project.web_hooks.all - @hook = WebHook.new + @hooks = @project.hooks.all + @hook = ProjectHook.new end def create - @hook = @project.web_hooks.new(params[:hook]) + @hook = @project.hooks.new(params[:hook]) @hook.save if @hook.valid? redirect_to project_hooks_path(@project) else - @hooks = @project.web_hooks.all + @hooks = @project.hooks.all render :index end end def test - @hook = @project.web_hooks.find(params[:id]) + @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) @@ -37,7 +37,7 @@ class HooksController < ApplicationController end def destroy - @hook = @project.web_hooks.find(params[:id]) + @hook = @project.hooks.find(params[:id]) @hook.destroy redirect_to project_hooks_path(@project) diff --git a/app/models/project.rb b/app/models/project.rb index ec4893e2b17..4773cf373f3 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -19,7 +19,7 @@ class Project < ActiveRecord::Base has_many :notes, :dependent => :destroy has_many :snippets, :dependent => :destroy has_many :deploy_keys, :dependent => :destroy, :foreign_key => "project_id", :class_name => "Key" - has_many :web_hooks, :dependent => :destroy + has_many :hooks, :dependent => :destroy, :class_name => "ProjectHook" has_many :wikis, :dependent => :destroy has_many :protected_branches, :dependent => :destroy diff --git a/app/models/project_hook.rb b/app/models/project_hook.rb new file mode 100644 index 00000000000..06388aaeb4c --- /dev/null +++ b/app/models/project_hook.rb @@ -0,0 +1,3 @@ +class ProjectHook < WebHook + belongs_to :project +end diff --git a/app/models/system_hook.rb b/app/models/system_hook.rb new file mode 100644 index 00000000000..178b7585d5b --- /dev/null +++ b/app/models/system_hook.rb @@ -0,0 +1,3 @@ +class SystemHook < WebHook + +end diff --git a/app/models/web_hook.rb b/app/models/web_hook.rb index 26288476a6c..43b4f16b846 100644 --- a/app/models/web_hook.rb +++ b/app/models/web_hook.rb @@ -4,8 +4,6 @@ class WebHook < ActiveRecord::Base # HTTParty timeout default_timeout 10 - belongs_to :project - validates :url, presence: true, format: { diff --git a/app/roles/git_push.rb b/app/roles/git_push.rb index b4c59472a5a..d0267b59b6d 100644 --- a/app/roles/git_push.rb +++ b/app/roles/git_push.rb @@ -35,7 +35,7 @@ module GitPush data = post_receive_data(oldrev, newrev, ref, user) - web_hooks.each { |web_hook| web_hook.execute(data) } + hooks.each { |web_hook| web_hook.execute(data) } end def post_receive_data(oldrev, newrev, ref, user) |
