Commit 5805e922 authored by Kamil Trzciński's avatar Kamil Trzciński Committed by Dylan Griffith

Improve Runners API validations

parent 385f37a7
...@@ -136,7 +136,7 @@ module API ...@@ -136,7 +136,7 @@ module API
if runner.assign_to(user_project) if runner.assign_to(user_project)
present runner, with: Entities::Runner present runner, with: Entities::Runner
else else
conflict!("Runner was already enabled for this project") render_validation_error!(runner)
end end
end end
......
...@@ -522,11 +522,7 @@ describe API::Runners do ...@@ -522,11 +522,7 @@ describe API::Runners do
describe 'POST /projects/:id/runners' do describe 'POST /projects/:id/runners' do
context 'authorized user' do context 'authorized user' do
let(:project_runner2) do let(:project_runner2) { create(:ci_runner, :project, projects: [project2]) }
create(:ci_runner).tap do |runner|
create(:ci_runner_project, runner: runner, project: project2)
end
end
it 'enables specific runner' do it 'enables specific runner' do
expect do expect do
...@@ -539,7 +535,7 @@ describe API::Runners do ...@@ -539,7 +535,7 @@ describe API::Runners do
expect do expect do
post api("/projects/#{project.id}/runners", user), runner_id: project_runner.id post api("/projects/#{project.id}/runners", user), runner_id: project_runner.id
end.to change { project.runners.count }.by(0) end.to change { project.runners.count }.by(0)
expect(response).to have_gitlab_http_status(409) expect(response).to have_gitlab_http_status(400)
end end
it 'does not enable locked runner' do it 'does not enable locked runner' do
......
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