diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-05-28 13:41:04 +0200 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-05-28 13:41:04 +0200 |
commit | 655c5bd05aadfe5992d90274d4e171cf1ac4e11d (patch) | |
tree | fb3631538b7827cdb497cd356d4d9939a8a0cf30 | |
parent | 1cbfb760b52397c5afcf17a9022b54a800724b74 (diff) | |
download | gitlab-ce-46010-add-more-validations-for-runners-and-runner-type-extra.tar.gz |
Improve Runners API validations46010-add-more-validations-for-runners-and-runner-type-extra
-rw-r--r-- | lib/api/runners.rb | 2 | ||||
-rw-r--r-- | spec/requests/api/runners_spec.rb | 8 |
2 files changed, 3 insertions, 7 deletions
diff --git a/lib/api/runners.rb b/lib/api/runners.rb index d9a42960cb6..2b78075ddbf 100644 --- a/lib/api/runners.rb +++ b/lib/api/runners.rb @@ -136,7 +136,7 @@ module API if runner.assign_to(user_project) present runner, with: Entities::Runner else - conflict!("Runner was already enabled for this project") + render_validation_error!(runner) end end diff --git a/spec/requests/api/runners_spec.rb b/spec/requests/api/runners_spec.rb index 4dfc3b8cfc4..cc326ff6484 100644 --- a/spec/requests/api/runners_spec.rb +++ b/spec/requests/api/runners_spec.rb @@ -522,11 +522,7 @@ describe API::Runners do describe 'POST /projects/:id/runners' do context 'authorized user' do - let(:project_runner2) do - create(:ci_runner).tap do |runner| - create(:ci_runner_project, runner: runner, project: project2) - end - end + let(:project_runner2) { create(:ci_runner, :project, projects: [project2]) } it 'enables specific runner' do expect do @@ -539,7 +535,7 @@ describe API::Runners do expect do post api("/projects/#{project.id}/runners", user), runner_id: project_runner.id 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 it 'does not enable locked runner' do |