Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexis Reigel <mail@koffeinfrei.org>2017-09-14 15:22:57 +0300
committerAlexis Reigel <alexis.reigel.ext@siemens.com>2018-01-04 11:33:41 +0300
commitb22ae0c00eaa6bad6e664953167022d17c196d8d (patch)
tree5b2146275ec7f0a836a9f3462ca219afffa045ff
parent9f7811e474a3f3f54f4624d19ec982239518ed67 (diff)
invoke SystemHooksService instead of direct model
-rw-r--r--app/models/project.rb4
-rw-r--r--spec/models/project_spec.rb10
2 files changed, 4 insertions, 10 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index a196c8b5c09..a8c634200ce 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -975,9 +975,7 @@ class Project < ActiveRecord::Base
end
end
- SystemHook.public_send(hooks_scope).each do |hook| # rubocop:disable GitlabSecurity/PublicSend
- hook.async_execute(data, hooks_scope.to_s)
- end
+ SystemHooksService.new.execute_hooks(data, hooks_scope)
end
def execute_services(data, hooks_scope = :push_hooks)
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 339186e25ae..e3899cc9bff 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -3190,14 +3190,10 @@ describe Project do
end
it 'executes the system hooks with the specified scope' do
- create :system_hook, merge_requests_events: true, tag_push_events: false
- create :system_hook, merge_requests_events: false, tag_push_events: true
- allow_any_instance_of(SystemHook).to receive(:async_execute).once
- project = create :project
+ expect_any_instance_of(SystemHooksService).to receive(:execute_hooks).with({ data: 'data' }, :merge_request_hooks)
- expect_any_instance_of(SystemHook).to receive(:async_execute).once
-
- project.execute_hooks({}, :tag_push_hooks)
+ project = build(:project)
+ project.execute_hooks({ data: 'data' }, :merge_request_hooks)
end
end
end