Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
c6e95b04
Commit
c6e95b04
authored
May 28, 2018
by
Kamil Trzciński
Committed by
Dylan Griffith
May 31, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve `Ci::Runner#assign_to` to return a flag whether it succeeded or not
parent
d9251f2e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
6 additions
and
12 deletions
+6
-12
app/controllers/admin/runner_projects_controller.rb
app/controllers/admin/runner_projects_controller.rb
+1
-3
app/controllers/projects/runner_projects_controller.rb
app/controllers/projects/runner_projects_controller.rb
+1
-2
app/models/ci/runner.rb
app/models/ci/runner.rb
+2
-3
lib/api/runners.rb
lib/api/runners.rb
+1
-3
spec/models/ci/runner_spec.rb
spec/models/ci/runner_spec.rb
+1
-1
No files found.
app/controllers/admin/runner_projects_controller.rb
View file @
c6e95b04
...
...
@@ -4,9 +4,7 @@ class Admin::RunnerProjectsController < Admin::ApplicationController
def
create
@runner
=
Ci
::
Runner
.
find
(
params
[
:runner_project
][
:runner_id
])
runner_project
=
@runner
.
assign_to
(
@project
,
current_user
)
if
runner_project
.
persisted?
if
@runner
.
assign_to
(
@project
,
current_user
)
redirect_to
admin_runner_path
(
@runner
)
else
redirect_to
admin_runner_path
(
@runner
),
alert:
'Failed adding runner to project'
...
...
app/controllers/projects/runner_projects_controller.rb
View file @
c6e95b04
...
...
@@ -9,9 +9,8 @@ class Projects::RunnerProjectsController < Projects::ApplicationController
return
head
(
403
)
unless
can?
(
current_user
,
:assign_runner
,
@runner
)
path
=
project_runners_path
(
project
)
runner_project
=
@runner
.
assign_to
(
project
,
current_user
)
if
runner_project
.
persisted?
if
@runner
.
assign_to
(
project
,
current_user
)
redirect_to
path
else
redirect_to
path
,
alert:
'Failed adding runner to project'
...
...
app/models/ci/runner.rb
View file @
c6e95b04
...
...
@@ -120,9 +120,8 @@ module Ci
raise
ArgumentError
,
'Transitioning a group runner to a project runner is not supported'
end
runner_project
=
project
.
runner_projects
.
create
(
runner_id:
self
.
id
)
self
.
save!
runner_project
self
.
projects
<<
project
self
.
save
end
def
display_name
...
...
lib/api/runners.rb
View file @
c6e95b04
...
...
@@ -133,9 +133,7 @@ module API
runner
=
get_runner
(
params
[
:runner_id
])
authenticate_enable_runner!
(
runner
)
runner_project
=
runner
.
assign_to
(
user_project
)
if
runner_project
.
persisted?
if
runner
.
assign_to
(
user_project
)
present
runner
,
with:
Entities
::
Runner
else
conflict!
(
"Runner was already enabled for this project"
)
...
...
spec/models/ci/runner_spec.rb
View file @
c6e95b04
...
...
@@ -200,7 +200,7 @@ describe Ci::Runner do
let
(
:runner
)
{
create
(
:ci_runner
,
:instance
)
}
it
'transitions shared runner to project runner and assigns project'
do
subject
expect
(
subject
).
to
be_truthy
expect
(
runner
).
to
be_specific
expect
(
runner
).
to
be_project_type
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment