summaryrefslogtreecommitdiff
path: root/spec/models/project_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/project_spec.rb')
-rw-r--r--spec/models/project_spec.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 5f4a3dbd99c..d7c4695203d 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -4812,6 +4812,32 @@ describe Project do
end
end
+ describe '#execute_services' do
+ let(:service) { create(:slack_service, push_events: true, merge_requests_events: false, active: true) }
+
+ it 'executes services with the specified scope' do
+ data = 'any data'
+
+ expect(SlackService).to receive(:allocate).and_wrap_original do |method|
+ method.call.tap do |instance|
+ expect(instance).to receive(:async_execute).with(data).once
+ end
+ end
+
+ service.project.execute_services(data, :push_hooks)
+ end
+
+ it 'does not execute services that don\'t match the specified scope' do
+ expect(SlackService).not_to receive(:allocate).and_wrap_original do |method|
+ method.call.tap do |instance|
+ expect(instance).not_to receive(:async_execute)
+ end
+ end
+
+ service.project.execute_services(anything, :merge_request_hooks)
+ end
+ end
+
describe '#has_active_hooks?' do
let_it_be(:project) { create(:project) }