summaryrefslogtreecommitdiff
path: root/spec/requests/api/runners_spec.rb
diff options
context:
space:
mode:
authorTomasz Maczukin <tomasz@maczukin.pl>2016-02-02 15:52:02 +0100
committerTomasz Maczukin <tomasz@maczukin.pl>2016-02-19 13:18:47 +0100
commit81ced6f55b1ab847bbb21da9c43410340c95c2b3 (patch)
tree7b98c9f8a1d6b6d148f44e69d2bcb9b6767c216b /spec/requests/api/runners_spec.rb
parentb56ee397bb5fa32e3a53fdaee3d6592f1486d7f1 (diff)
downloadgitlab-ce-81ced6f55b1ab847bbb21da9c43410340c95c2b3.tar.gz
Split `/runners` entrypoint to `/runners` and `/runners/all`
Diffstat (limited to 'spec/requests/api/runners_spec.rb')
-rw-r--r--spec/requests/api/runners_spec.rb54
1 files changed, 43 insertions, 11 deletions
diff --git a/spec/requests/api/runners_spec.rb b/spec/requests/api/runners_spec.rb
index d600b2312c5..a3c96777b92 100644
--- a/spec/requests/api/runners_spec.rb
+++ b/spec/requests/api/runners_spec.rb
@@ -23,9 +23,44 @@ describe API::API, api: true do
describe 'GET /runners' do
context 'authorized user' do
- context 'authorized user with admin privileges' do
+ it 'should return user available runners' do
+ get api('/runners', user)
+ shared = false || json_response.map{ |r| r['is_shared'] }.inject{ |sum, shr| sum || shr}
+
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(shared).to be_falsey
+ end
+
+ it 'should filter runners by scope' do
+ get api('/runners?scope=specific', user)
+ shared = false || json_response.map{ |r| r['is_shared'] }.inject{ |sum, shr| sum || shr}
+
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(shared).to be_falsey
+ end
+
+ it 'should avoid filtering if scope is invalid' do
+ get api('/runners?scope=unknown', user)
+ expect(response.status).to eq(400)
+ end
+ end
+
+ context 'unauthorized user' do
+ it 'should not return runners' do
+ get api('/runners')
+
+ expect(response.status).to eq(401)
+ end
+ end
+ end
+
+ describe 'GET /runners/all' do
+ context 'authorized user' do
+ context 'with admin privileges' do
it 'should return all runners' do
- get api('/runners', admin)
+ get api('/runners/all', admin)
shared = false || json_response.map{ |r| r['is_shared'] }.inject{ |sum, shr| sum || shr}
expect(response.status).to eq(200)
@@ -34,19 +69,16 @@ describe API::API, api: true do
end
end
- context 'authorized user without admin privileges' do
- it 'should return user available runners' do
- get api('/runners', user)
- shared = false || json_response.map{ |r| r['is_shared'] }.inject{ |sum, shr| sum || shr}
+ context 'without admin privileges' do
+ it 'should not return runners list' do
+ get api('/runners/all', user)
- expect(response.status).to eq(200)
- expect(json_response).to be_an Array
- expect(shared).to be_falsey
+ expect(response.status).to eq(403)
end
end
it 'should filter runners by scope' do
- get api('/runners?scope=specific', user)
+ get api('/runners?scope=specific', admin)
shared = false || json_response.map{ |r| r['is_shared'] }.inject{ |sum, shr| sum || shr}
expect(response.status).to eq(200)
@@ -55,7 +87,7 @@ describe API::API, api: true do
end
it 'should avoid filtering if scope is invalid' do
- get api('/runners?scope=unknown', user)
+ get api('/runners?scope=unknown', admin)
expect(response.status).to eq(400)
end
end