Commit 16b3368a authored by Tomasz Maczukin's avatar Tomasz Maczukin

Fix runners API spec

parent 81ced6f5
...@@ -316,24 +316,24 @@ describe API::API, api: true do ...@@ -316,24 +316,24 @@ describe API::API, api: true do
end end
end end
describe 'PUT /projects/:id/runners/:runner_id' do describe 'POST /projects/:id/runners/:runner_id' do
context 'authorized user' do context 'authorized user' do
it 'should enable specific runner' do it 'should enable specific runner' do
expect do expect do
put api("/projects/#{project.id}/runners/#{specific_runner2.id}", user) post api("/projects/#{project.id}/runners/#{specific_runner2.id}", user)
end.to change{ project.runners.count }.by(+1) end.to change{ project.runners.count }.by(+1)
expect(response.status).to eq(200) expect(response.status).to eq(201)
end end
it 'should avoid changes when enabling already enabled runner' do it 'should avoid changes when enabling already enabled runner' do
expect do expect do
put api("/projects/#{project.id}/runners/#{specific_runner.id}", user) post api("/projects/#{project.id}/runners/#{specific_runner.id}", user)
end.to change{ project.runners.count }.by(0) end.to change{ project.runners.count }.by(0)
expect(response.status).to eq(200) expect(response.status).to eq(201)
end end
it 'should not enable shared runner' do it 'should not enable shared runner' do
put api("/projects/#{project.id}/runners/#{shared_runner.id}", user) post api("/projects/#{project.id}/runners/#{shared_runner.id}", user)
expect(response.status).to eq(403) expect(response.status).to eq(403)
end end
...@@ -341,15 +341,15 @@ describe API::API, api: true do ...@@ -341,15 +341,15 @@ describe API::API, api: true do
context 'user is admin' do context 'user is admin' do
it 'should enable any specific runner' do it 'should enable any specific runner' do
expect do expect do
put api("/projects/#{project.id}/runners/#{unused_specific_runner.id}", admin) post api("/projects/#{project.id}/runners/#{unused_specific_runner.id}", admin)
end.to change{ project.runners.count }.by(+1) end.to change{ project.runners.count }.by(+1)
expect(response.status).to eq(200) expect(response.status).to eq(201)
end end
end end
context 'user is not admin' do context 'user is not admin' do
it 'should not enable runner without access to' do it 'should not enable runner without access to' do
put api("/projects/#{project.id}/runners/#{unused_specific_runner.id}", user) post api("/projects/#{project.id}/runners/#{unused_specific_runner.id}", user)
expect(response.status).to eq(403) expect(response.status).to eq(403)
end end
...@@ -358,7 +358,7 @@ describe API::API, api: true do ...@@ -358,7 +358,7 @@ describe API::API, api: true do
context 'authorized user without permissions' do context 'authorized user without permissions' do
it 'should not enable runner' do it 'should not enable runner' do
put api("/projects/#{project.id}/runners/#{specific_runner2.id}", user2) post api("/projects/#{project.id}/runners/#{specific_runner2.id}", user2)
expect(response.status).to eq(403) expect(response.status).to eq(403)
end end
...@@ -366,7 +366,7 @@ describe API::API, api: true do ...@@ -366,7 +366,7 @@ describe API::API, api: true do
context 'unauthorized user' do context 'unauthorized user' do
it 'should not enable runner' do it 'should not enable runner' do
put api("/projects/#{project.id}/runners/#{specific_runner2.id}") post api("/projects/#{project.id}/runners/#{specific_runner2.id}")
expect(response.status).to eq(401) expect(response.status).to eq(401)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment