Skip to content
Snippets Groups Projects
Commit f74f4238 authored by Lin Jen-Shin's avatar Lin Jen-Shin
Browse files

Give 409 Conflict whenever the runner was already enabled

parent 1b03c580
No related branches found
No related tags found
3 merge requests!4734!4093 is giving me 502,!4641Prefer Runner#assign_to instead of creating directly,!4093Make it possible to lock runner on a specific project
Pipeline #
Loading
Loading
@@ -40,6 +40,7 @@ v 8.9.0 (unreleased)
- Added artifacts:when to .gitlab-ci.yml - this requires GitLab Runner 1.3
- Todos will display target state if issuable target is 'Closed' or 'Merged'
- Fix bug when sorting issues by milestone due date and filtering by two or more labels
- POST to API /projects/:id/runners/:runner_id would give 409 if the runner was already enabled for this project
- Add support for using Yubikeys (U2F) for two-factor authentication
- Link to blank group icon doesn't throw a 404 anymore
- Remove 'main language' feature
Loading
Loading
Loading
Loading
@@ -56,7 +56,7 @@ module Ci
def assign_to(project, current_user = nil)
self.is_shared = false if shared?
self.save
project.runner_projects.create(runner_id: self.id)
project.runner_projects.create(runner_id: self.id).persisted?
end
 
def display_name
Loading
Loading
Loading
Loading
@@ -96,9 +96,12 @@ module API
 
runner = get_runner(params[:runner_id])
authenticate_enable_runner!(runner)
runner.assign_to(user_project)
 
present runner, with: Entities::Runner
if runner.assign_to(user_project)
present runner, with: Entities::Runner
else
conflict!("Runner was already enabled for this project")
end
end
 
# Disable project's runner
Loading
Loading
Loading
Loading
@@ -375,7 +375,7 @@ describe API::Runners, api: true do
expect do
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)
expect(response.status).to eq(409)
end
 
it 'should not enable shared runner' do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment