summaryrefslogtreecommitdiff
path: root/spec/requests/api/v3/system_hooks_spec.rb
diff options
context:
space:
mode:
authorRobert Schilling <rschilling@student.tugraz.at>2017-02-06 19:38:17 +0100
committerRobert Schilling <rschilling@student.tugraz.at>2017-02-17 09:05:24 +0100
commitce54a801feb62c768042587685b5848e06f0a6da (patch)
tree34e686eeabd11ade916fadf5c9c833394567834e /spec/requests/api/v3/system_hooks_spec.rb
parentc70dfbc68614658c98a0f17a01413844a2a98abf (diff)
downloadgitlab-ce-ce54a801feb62c768042587685b5848e06f0a6da.tar.gz
Backport API to v3paginate-all-the-things
Diffstat (limited to 'spec/requests/api/v3/system_hooks_spec.rb')
-rw-r--r--spec/requests/api/v3/system_hooks_spec.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/requests/api/v3/system_hooks_spec.rb b/spec/requests/api/v3/system_hooks_spec.rb
new file mode 100644
index 00000000000..da58efb6ebf
--- /dev/null
+++ b/spec/requests/api/v3/system_hooks_spec.rb
@@ -0,0 +1,41 @@
+require 'spec_helper'
+
+describe API::V3::SystemHooks, api: true do
+ include ApiHelpers
+
+ let(:user) { create(:user) }
+ let(:admin) { create(:admin) }
+ let!(:hook) { create(:system_hook, url: "http://example.com") }
+
+ before { stub_request(:post, hook.url) }
+
+ describe "GET /hooks" do
+ context "when no user" do
+ it "returns authentication error" do
+ get v3_api("/hooks")
+
+ expect(response).to have_http_status(401)
+ end
+ end
+
+ context "when not an admin" do
+ it "returns forbidden error" do
+ get v3_api("/hooks", user)
+
+ expect(response).to have_http_status(403)
+ end
+ end
+
+ context "when authenticated as admin" do
+ it "returns an array of hooks" do
+ get v3_api("/hooks", admin)
+
+ expect(response).to have_http_status(200)
+ expect(json_response).to be_an Array
+ expect(json_response.first['url']).to eq(hook.url)
+ expect(json_response.first['push_events']).to be true
+ expect(json_response.first['tag_push_events']).to be false
+ end
+ end
+ end
+end