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
Jérome Perrin
gitlab-ce
Commits
d3bcb06d
Commit
d3bcb06d
authored
Jul 04, 2018
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make deprecated scopes of Runner explicit
parent
ca93faf1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
3 deletions
+19
-3
app/models/ci/runner.rb
app/models/ci/runner.rb
+2
-2
lib/api/runners.rb
lib/api/runners.rb
+5
-0
spec/requests/api/runners_spec.rb
spec/requests/api/runners_spec.rb
+12
-1
No files found.
app/models/ci/runner.rb
View file @
d3bcb06d
...
@@ -30,9 +30,9 @@ module Ci
...
@@ -30,9 +30,9 @@ module Ci
scope
:ordered
,
->
{
order
(
id: :desc
)
}
scope
:ordered
,
->
{
order
(
id: :desc
)
}
# BACKWARD COMPATIBILITY: There are needed to maintain compatibility with `AVAILABLE_SCOPES` used by `lib/api/runners.rb`
# BACKWARD COMPATIBILITY: There are needed to maintain compatibility with `AVAILABLE_SCOPES` used by `lib/api/runners.rb`
scope
:shared
,
->
{
instance_type
}
scope
:
deprecated_
shared
,
->
{
instance_type
}
# this should get replaced with `project_type.or(group_type)` once using Rails5
# this should get replaced with `project_type.or(group_type)` once using Rails5
scope
:specific
,
->
{
where
(
runner_type:
[
runner_types
[
:project_type
],
runner_types
[
:group_type
]])
}
scope
:
deprecated_
specific
,
->
{
where
(
runner_type:
[
runner_types
[
:project_type
],
runner_types
[
:group_type
]])
}
scope
:belonging_to_project
,
->
(
project_id
)
{
scope
:belonging_to_project
,
->
(
project_id
)
{
joins
(
:runner_projects
).
where
(
ci_runner_projects:
{
project_id:
project_id
})
joins
(
:runner_projects
).
where
(
ci_runner_projects:
{
project_id:
project_id
})
...
...
lib/api/runners.rb
View file @
d3bcb06d
...
@@ -170,6 +170,11 @@ module API
...
@@ -170,6 +170,11 @@ module API
render_api_error!
(
'Scope contains invalid value'
,
400
)
render_api_error!
(
'Scope contains invalid value'
,
400
)
end
end
# Support deprecated scopes
if
runners
.
respond_to?
(
"deprecated_
#{
scope
}
"
)
scope
=
"deprecated_
#{
scope
}
"
end
runners
.
public_send
(
scope
)
# rubocop:disable GitlabSecurity/PublicSend
runners
.
public_send
(
scope
)
# rubocop:disable GitlabSecurity/PublicSend
end
end
...
...
spec/requests/api/runners_spec.rb
View file @
d3bcb06d
...
@@ -89,6 +89,17 @@ describe API::Runners do
...
@@ -89,6 +89,17 @@ describe API::Runners do
end
end
end
end
it
'filters runners by scope'
do
get
api
(
'/runners/all?scope=shared'
,
admin
)
shared
=
json_response
.
all?
{
|
r
|
r
[
'is_shared'
]
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
[
0
]).
to
have_key
(
'ip_address'
)
expect
(
shared
).
to
be_truthy
end
it
'filters runners by scope'
do
it
'filters runners by scope'
do
get
api
(
'/runners/all?scope=specific'
,
admin
)
get
api
(
'/runners/all?scope=specific'
,
admin
)
...
@@ -584,7 +595,7 @@ describe API::Runners do
...
@@ -584,7 +595,7 @@ describe API::Runners do
end
end
end
end
it
'enables a instance
-wid
e runner'
do
it
'enables a instance
typ
e runner'
do
expect
do
expect
do
post
api
(
"/projects/
#{
project
.
id
}
/runners"
,
admin
),
runner_id:
shared_runner
.
id
post
api
(
"/projects/
#{
project
.
id
}
/runners"
,
admin
),
runner_id:
shared_runner
.
id
end
.
to
change
{
project
.
runners
.
count
}.
by
(
1
)
end
.
to
change
{
project
.
runners
.
count
}.
by
(
1
)
...
...
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