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-20 11:41:43 +0300
committerAlexis Reigel <alexis.reigel.ext@siemens.com>2018-01-04 11:33:41 +0300
commitd71d8ad7f8363d7ffa55d52e1dcbc6bfadaf070e (patch)
treeb83e6250a2c8b2081a15d856d1829d8acf8aacd7 /spec/services/test_hooks/system_service_spec.rb
parentb22ae0c00eaa6bad6e664953167022d17c196d8d (diff)
test hook for system merge request hook
Diffstat (limited to 'spec/services/test_hooks/system_service_spec.rb')
-rw-r--r--spec/services/test_hooks/system_service_spec.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/services/test_hooks/system_service_spec.rb b/spec/services/test_hooks/system_service_spec.rb
index ff8b9595538..74d7715e50f 100644
--- a/spec/services/test_hooks/system_service_spec.rb
+++ b/spec/services/test_hooks/system_service_spec.rb
@@ -60,5 +60,25 @@ describe TestHooks::SystemService do
expect(service.execute).to include(success_result)
end
end
+
+ context 'merge_requests_events' do
+ let(:trigger) { 'merge_requests_events' }
+
+ it 'returns error message if the user does not have any repository with a merge request' do
+ expect(hook).not_to receive(:execute)
+ expect(service.execute).to include({ status: :error, message: 'Ensure one of your projects has merge requests.' })
+ end
+
+ it 'executes hook' do
+ trigger_key = :merge_request_hooks
+ sample_data = { data: 'sample' }
+ create(:project_member, user: current_user, project: project)
+ create(:merge_request, source_project: project)
+ allow_any_instance_of(MergeRequest).to receive(:to_hook_data).and_return(sample_data)
+
+ expect(hook).to receive(:execute).with(sample_data, trigger_key).and_return(success_result)
+ expect(service.execute).to include(success_result)
+ end
+ end
end
end