diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-01-18 11:37:16 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-01-18 11:37:16 +0000 |
commit | 8e9c073a146f655cea2fd13f259bd68dc2c37259 (patch) | |
tree | 01bd2ec14fd6406b1deb1947935b36463a7e4529 /app/services | |
parent | d617c24f59f9cc1c068301ec755caa2de6cd6b73 (diff) | |
parent | 6ef1b94ccf9eb60d5cff43d7e1302129d1b43cc3 (diff) | |
download | gitlab-ce-8e9c073a146f655cea2fd13f259bd68dc2c37259.tar.gz |
Merge branch 'feature/merge-request-system-hook' into 'master'
System hooks for Merge Requests
See merge request gitlab-org/gitlab-ce!14387
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/system_hooks_service.rb | 2 | ||||
-rw-r--r-- | app/services/test_hooks/base_service.rb | 2 | ||||
-rw-r--r-- | app/services/test_hooks/system_service.rb | 7 |
3 files changed, 9 insertions, 2 deletions
diff --git a/app/services/system_hooks_service.rb b/app/services/system_hooks_service.rb index af6d77ef5e8..a6b7a6e1416 100644 --- a/app/services/system_hooks_service.rb +++ b/app/services/system_hooks_service.rb @@ -8,7 +8,7 @@ class SystemHooksService end def execute_hooks(data, hooks_scope = :all) - SystemHook.public_send(hooks_scope).find_each do |hook| # rubocop:disable GitlabSecurity/PublicSend + SystemHook.hooks_for(hooks_scope).find_each do |hook| hook.async_execute(data, 'system_hooks') end end diff --git a/app/services/test_hooks/base_service.rb b/app/services/test_hooks/base_service.rb index 20d90504bd2..e9aefb1fb75 100644 --- a/app/services/test_hooks/base_service.rb +++ b/app/services/test_hooks/base_service.rb @@ -9,7 +9,7 @@ module TestHooks end def execute - trigger_key = hook.class::TRIGGERS.key(trigger.to_sym) + trigger_key = hook.class.triggers.key(trigger.to_sym) trigger_data_method = "#{trigger}_data" if trigger_key.nil? || !self.respond_to?(trigger_data_method, true) diff --git a/app/services/test_hooks/system_service.rb b/app/services/test_hooks/system_service.rb index 67552edefc9..9016c77b7f0 100644 --- a/app/services/test_hooks/system_service.rb +++ b/app/services/test_hooks/system_service.rb @@ -13,5 +13,12 @@ module TestHooks def repository_update_events_data Gitlab::DataBuilder::Repository.sample_data end + + def merge_requests_events_data + merge_request = MergeRequest.of_projects(current_user.projects.select(:id)).first + throw(:validation_error, 'Ensure one of your projects has merge requests.') unless merge_request.present? + + merge_request.to_hook_data(current_user) + end end end |