Allow admin to assign shared runner to project through API
This commit is contained in:
parent
8583e4a147
commit
b35d16a77f
|
@ -203,11 +203,11 @@ module API
|
||||||
end
|
end
|
||||||
|
|
||||||
def authenticate_enable_runner!(runner)
|
def authenticate_enable_runner!(runner)
|
||||||
forbidden!("Runner is shared") if runner.is_shared?
|
|
||||||
forbidden!("Runner is locked") if runner.locked?
|
|
||||||
forbidden!("Runner is a group runner") if runner.group_type?
|
forbidden!("Runner is a group runner") if runner.group_type?
|
||||||
|
|
||||||
return if current_user.admin?
|
return if current_user.admin?
|
||||||
|
|
||||||
|
forbidden!("Runner is locked") if runner.locked?
|
||||||
forbidden!("No access granted") unless can?(current_user, :assign_runner, runner)
|
forbidden!("No access granted") unless can?(current_user, :assign_runner, runner)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -592,6 +592,15 @@ describe API::Runners do
|
||||||
end.to change { project.runners.count }.by(+1)
|
end.to change { project.runners.count }.by(+1)
|
||||||
expect(response).to have_gitlab_http_status(201)
|
expect(response).to have_gitlab_http_status(201)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'enables a shared runner' do
|
||||||
|
expect do
|
||||||
|
post api("/projects/#{project.id}/runners", admin), runner_id: shared_runner.id
|
||||||
|
end.to change { project.runners.count }.by(1)
|
||||||
|
|
||||||
|
expect(shared_runner.reload).not_to be_shared
|
||||||
|
expect(response).to have_gitlab_http_status(201)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'user is not admin' do
|
context 'user is not admin' do
|
||||||
|
|
Loading…
Reference in New Issue