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
b35d16a7
Commit
b35d16a7
authored
May 11, 2018
by
Dylan Griffith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow admin to assign shared runner to project through API
parent
8583e4a1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
2 deletions
+11
-2
lib/api/runners.rb
lib/api/runners.rb
+2
-2
spec/requests/api/runners_spec.rb
spec/requests/api/runners_spec.rb
+9
-0
No files found.
lib/api/runners.rb
View file @
b35d16a7
...
@@ -203,11 +203,11 @@ module API
...
@@ -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
...
...
spec/requests/api/runners_spec.rb
View file @
b35d16a7
...
@@ -592,6 +592,15 @@ describe API::Runners do
...
@@ -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
...
...
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