diff options
author | Alexis Reigel <alexis.reigel.ext@siemens.com> | 2017-11-23 16:45:00 +0100 |
---|---|---|
committer | Alexis Reigel <alexis.reigel.ext@siemens.com> | 2018-01-04 09:33:41 +0100 |
commit | 2a0a7b426e63dac685654cafb0904e7668ad1fde (patch) | |
tree | 93440648b4ab2ed5be6f75e847ae26b1d2bc7365 | |
parent | 9a5bfcfdc53bf9b6217121b8639b43cc603f91c1 (diff) | |
download | gitlab-ce-2a0a7b426e63dac685654cafb0904e7668ad1fde.tar.gz |
api support for merge_requests_events system hook
-rw-r--r-- | doc/api/system_hooks.md | 1 | ||||
-rw-r--r-- | lib/api/entities.rb | 4 | ||||
-rw-r--r-- | lib/api/system_hooks.rb | 1 | ||||
-rw-r--r-- | spec/requests/api/system_hooks_spec.rb | 20 |
4 files changed, 23 insertions, 3 deletions
diff --git a/doc/api/system_hooks.md b/doc/api/system_hooks.md index 9750475f0a6..482f5083bb2 100644 --- a/doc/api/system_hooks.md +++ b/doc/api/system_hooks.md @@ -33,6 +33,7 @@ Example response: "created_at":"2016-10-31T12:32:15.192Z", "push_events":true, "tag_push_events":false, + "merge_requests_events": true, "enable_ssl_verification":true } ] diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 4ad4a1f7867..d09402b1c1c 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -65,12 +65,12 @@ module API end class Hook < Grape::Entity - expose :id, :url, :created_at, :push_events, :tag_push_events, :repository_update_events + expose :id, :url, :created_at, :push_events, :tag_push_events, :merge_requests_events, :repository_update_events expose :enable_ssl_verification end class ProjectHook < Hook - expose :project_id, :issues_events, :merge_requests_events + expose :project_id, :issues_events expose :note_events, :pipeline_events, :wiki_page_events expose :job_events end diff --git a/lib/api/system_hooks.rb b/lib/api/system_hooks.rb index 6b6a03e3300..c7a460df46a 100644 --- a/lib/api/system_hooks.rb +++ b/lib/api/system_hooks.rb @@ -26,6 +26,7 @@ module API optional :token, type: String, desc: 'The token used to validate payloads' optional :push_events, type: Boolean, desc: "Trigger hook on push events" optional :tag_push_events, type: Boolean, desc: "Trigger hook on tag push events" + optional :merge_requests_events, type: Boolean, desc: "Trigger hook on tag push events" optional :enable_ssl_verification, type: Boolean, desc: "Do SSL verification when triggering the hook" end post do diff --git a/spec/requests/api/system_hooks_spec.rb b/spec/requests/api/system_hooks_spec.rb index c7a009e999e..6c57d443cbf 100644 --- a/spec/requests/api/system_hooks_spec.rb +++ b/spec/requests/api/system_hooks_spec.rb @@ -36,6 +36,7 @@ describe API::SystemHooks do expect(json_response.first['url']).to eq(hook.url) expect(json_response.first['push_events']).to be false expect(json_response.first['tag_push_events']).to be false + expect(json_response.first['merge_requests_events']).to be false expect(json_response.first['repository_update_events']).to be true end end @@ -67,11 +68,28 @@ describe API::SystemHooks do end it 'sets default values for events' do - post api('/hooks', admin), url: 'http://mep.mep', enable_ssl_verification: true + post api('/hooks', admin), url: 'http://mep.mep' expect(response).to have_gitlab_http_status(201) expect(json_response['enable_ssl_verification']).to be true + expect(json_response['push_events']).to be false expect(json_response['tag_push_events']).to be false + expect(json_response['merge_requests_events']).to be false + end + + it 'sets explicit values for events' do + post api('/hooks', admin), + url: 'http://mep.mep', + enable_ssl_verification: false, + push_events: true, + tag_push_events: true, + merge_requests_events: true + + expect(response).to have_http_status(201) + expect(json_response['enable_ssl_verification']).to be false + expect(json_response['push_events']).to be true + expect(json_response['tag_push_events']).to be true + expect(json_response['merge_requests_events']).to be true end end |