Commit 25951b914619a9e056122f0c39ce64e4afe453d8
1 parent
0687ecb6
Exists in
master
and in
4 other branches
Prepare ProjectHooks to work with issues and merge_requests
* Add event scopes to ProjectHook * Added Issuable#to_hook_data * Project#execute_hooks now accept hook filter as argument Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
3 changed files
with
15 additions
and
2 deletions
Show diff stats
app/models/concerns/issuable.rb
app/models/project.rb
... | ... | @@ -298,8 +298,10 @@ class Project < ActiveRecord::Base |
298 | 298 | ProjectTransferService.new.transfer(self, new_namespace) |
299 | 299 | end |
300 | 300 | |
301 | - def execute_hooks(data) | |
302 | - hooks.each { |hook| hook.async_execute(data) } | |
301 | + def execute_hooks(data, hooks_scope = :push_hooks) | |
302 | + hooks.send(hooks_scope).each do |hook| | |
303 | + hook.async_execute(data) | |
304 | + end | |
303 | 305 | end |
304 | 306 | |
305 | 307 | def execute_services(data) | ... | ... |
app/models/project_hook.rb
... | ... | @@ -15,4 +15,8 @@ class ProjectHook < WebHook |
15 | 15 | belongs_to :project |
16 | 16 | |
17 | 17 | attr_accessible :push_events, :issues_events, :merge_requests_events |
18 | + | |
19 | + scope :push_hooks, -> { where(push_events: true) } | |
20 | + scope :issue_hooks, -> { where(issues_events: true) } | |
21 | + scope :merge_request_hooks, -> { where(merge_requests_events: true) } | |
18 | 22 | end | ... | ... |