diff options
author | Rémy Coutable <remy@rymai.me> | 2016-11-08 10:02:48 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-11-08 10:02:48 +0000 |
commit | 67ca15bb671be304330dd17d15a02c8c3563ce97 (patch) | |
tree | ecbe3c51cbd8e40a304d5bf7e43198c5aa610103 | |
parent | 55e0065b49d63f53c40876196d8f110e4eb3ea32 (diff) | |
parent | 659ef54605e37ba750486f25957ec367264dffd4 (diff) | |
download | gitlab-ce-67ca15bb671be304330dd17d15a02c8c3563ce97.tar.gz |
Merge branch 'fix-systemhook-api' into 'master'
API: Return 400 when creating a systemhook fails
Closes #23335
See merge request !7350
-rw-r--r-- | changelogs/unreleased/api-return-400-if-post-systemhook-fails.yml | 4 | ||||
-rw-r--r-- | lib/api/system_hooks.rb | 2 | ||||
-rw-r--r-- | spec/requests/api/system_hooks_spec.rb | 6 |
3 files changed, 11 insertions, 1 deletions
diff --git a/changelogs/unreleased/api-return-400-if-post-systemhook-fails.yml b/changelogs/unreleased/api-return-400-if-post-systemhook-fails.yml new file mode 100644 index 00000000000..d132d7e79c3 --- /dev/null +++ b/changelogs/unreleased/api-return-400-if-post-systemhook-fails.yml @@ -0,0 +1,4 @@ +--- +title: Return 400 when creating a system hook fails +merge_request: 7350 +author: Robert Schilling diff --git a/lib/api/system_hooks.rb b/lib/api/system_hooks.rb index 32f731c5652..b6bfff9f20f 100644 --- a/lib/api/system_hooks.rb +++ b/lib/api/system_hooks.rb @@ -32,7 +32,7 @@ module API if hook.save present hook, with: Entities::Hook else - not_found! + render_validation_error!(hook) end end diff --git a/spec/requests/api/system_hooks_spec.rb b/spec/requests/api/system_hooks_spec.rb index f685a3685e6..6c9df21f598 100644 --- a/spec/requests/api/system_hooks_spec.rb +++ b/spec/requests/api/system_hooks_spec.rb @@ -52,6 +52,12 @@ describe API::API, api: true do expect(response).to have_http_status(400) end + it "responds with 400 if url is invalid" do + post api("/hooks", admin), url: 'hp://mep.mep' + + expect(response).to have_http_status(400) + end + it "does not create new hook without url" do expect do post api("/hooks", admin) |