summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2016-12-20 14:36:50 +0000
committerSean McGivern <sean@mcgivern.me.uk>2016-12-20 14:36:50 +0000
commitd84cfeaf21bb60c09061ad6c7bf135c37d063162 (patch)
treef9a1fceb8d6b9f21c79464484fd599bdecb6d38c /spec/support
parent1139da2745eb28be17c8fd6aa0f5de113c0f06a9 (diff)
parentc87d93d462bb83caebd22bd759d8a1ead845d6a4 (diff)
downloadgitlab-ce-d84cfeaf21bb60c09061ad6c7bf135c37d063162.tar.gz
Merge branch '4269-public-repositories-api' into 'master'
Allow Repositories API GET endpoints to be requested anonymously Closes #4269 See merge request !8148
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/api/status_shared_examples.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/support/api/status_shared_examples.rb b/spec/support/api/status_shared_examples.rb
new file mode 100644
index 00000000000..3481749a7f0
--- /dev/null
+++ b/spec/support/api/status_shared_examples.rb
@@ -0,0 +1,42 @@
+# Specs for status checking.
+#
+# Requires an API request:
+# let(:request) { get api("/projects/#{project.id}/repository/branches", user) }
+shared_examples_for '400 response' do
+ before do
+ # Fires the request
+ request
+ end
+
+ it 'returns 400' do
+ expect(response).to have_http_status(400)
+ end
+end
+
+shared_examples_for '403 response' do
+ before do
+ # Fires the request
+ request
+ end
+
+ it 'returns 403' do
+ expect(response).to have_http_status(403)
+ end
+end
+
+shared_examples_for '404 response' do
+ let(:message) { nil }
+ before do
+ # Fires the request
+ request
+ end
+
+ it 'returns 404' do
+ expect(response).to have_http_status(404)
+ expect(json_response).to be_an Object
+
+ if message.present?
+ expect(json_response['message']).to eq(message)
+ end
+ end
+end