summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Schilling <rschilling@student.tugraz.at>2016-11-08 10:05:19 +0100
committerRobert Schilling <rschilling@student.tugraz.at>2016-11-08 10:05:19 +0100
commit659ef54605e37ba750486f25957ec367264dffd4 (patch)
tree01180ac95071bf8b12a5cbf9d85f580e542ecc65
parentc392b0cc24ba40e3fed920c6c693cb24665193af (diff)
downloadgitlab-ce-659ef54605e37ba750486f25957ec367264dffd4.tar.gz
API: Return 400 when creating a systemhook fails
-rw-r--r--changelogs/unreleased/api-return-400-if-post-systemhook-fails.yml4
-rw-r--r--lib/api/system_hooks.rb2
-rw-r--r--spec/requests/api/system_hooks_spec.rb6
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)