summaryrefslogtreecommitdiff
path: root/spec/requests/api/runners_spec.rb
diff options
context:
space:
mode:
authorTomasz Maczukin <tomasz@maczukin.pl>2016-02-16 12:05:48 +0100
committerTomasz Maczukin <tomasz@maczukin.pl>2016-02-19 13:18:48 +0100
commitb36116f9ad3990cb0d5c81ecb6d5b306dc41fbd5 (patch)
treeb0bbb5bd46e58a808321f9a122ddee34b3badfc3 /spec/requests/api/runners_spec.rb
parentdc182dc50e61bc4d4cde3fb32ee29668ad24513b (diff)
downloadgitlab-ce-b36116f9ad3990cb0d5c81ecb6d5b306dc41fbd5.tar.gz
Move :runner_id param to POST body when enabling specific runner in project
Diffstat (limited to 'spec/requests/api/runners_spec.rb')
-rw-r--r--spec/requests/api/runners_spec.rb22
1 files changed, 14 insertions, 8 deletions
diff --git a/spec/requests/api/runners_spec.rb b/spec/requests/api/runners_spec.rb
index b95bfb15040..6261d0e840c 100644
--- a/spec/requests/api/runners_spec.rb
+++ b/spec/requests/api/runners_spec.rb
@@ -337,27 +337,27 @@ describe API::API, api: true do
end
end
- describe 'POST /projects/:id/runners/:runner_id' do
+ describe 'POST /projects/:id/runners' do
let!(:specific_runner2) { create(:ci_specific_runner) }
let!(:specific_runner2_project) { create(:ci_runner_project, runner: specific_runner2, project: project2) }
context 'authorized user' do
it 'should enable specific runner' do
expect do
- post api("/projects/#{project.id}/runners/#{specific_runner2.id}", user)
+ post api("/projects/#{project.id}/runners", user), runner_id: specific_runner2.id
end.to change{ project.runners.count }.by(+1)
expect(response.status).to eq(201)
end
it 'should avoid changes when enabling already enabled runner' do
expect do
- post api("/projects/#{project.id}/runners/#{specific_runner.id}", user)
+ post api("/projects/#{project.id}/runners", user), runner_id: specific_runner.id
end.to change{ project.runners.count }.by(0)
expect(response.status).to eq(201)
end
it 'should not enable shared runner' do
- post api("/projects/#{project.id}/runners/#{shared_runner.id}", user)
+ post api("/projects/#{project.id}/runners", user), runner_id: shared_runner.id
expect(response.status).to eq(403)
end
@@ -365,7 +365,7 @@ describe API::API, api: true do
context 'user is admin' do
it 'should enable any specific runner' do
expect do
- post api("/projects/#{project.id}/runners/#{unused_specific_runner.id}", admin)
+ post api("/projects/#{project.id}/runners", admin), runner_id: unused_specific_runner.id
end.to change{ project.runners.count }.by(+1)
expect(response.status).to eq(201)
end
@@ -373,16 +373,22 @@ describe API::API, api: true do
context 'user is not admin' do
it 'should not enable runner without access to' do
- post api("/projects/#{project.id}/runners/#{unused_specific_runner.id}", user)
+ post api("/projects/#{project.id}/runners", user), runner_id: unused_specific_runner.id
expect(response.status).to eq(403)
end
end
+
+ it 'should raise an error when no runner_id param is provided' do
+ post api("/projects/#{project.id}/runners", admin)
+
+ expect(response.status).to eq(400)
+ end
end
context 'authorized user without permissions' do
it 'should not enable runner' do
- post api("/projects/#{project.id}/runners/#{specific_runner2.id}", user2)
+ post api("/projects/#{project.id}/runners", user2), runner_id: specific_runner2.id
expect(response.status).to eq(403)
end
@@ -390,7 +396,7 @@ describe API::API, api: true do
context 'unauthorized user' do
it 'should not enable runner' do
- post api("/projects/#{project.id}/runners/#{specific_runner2.id}")
+ post api("/projects/#{project.id}/runners"), runner_id: specific_runner2.id
expect(response.status).to eq(401)
end