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
8dad45a8
Commit
8dad45a8
authored
Oct 04, 2017
by
Alexis Reigel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add method CI::Runner.project?
parent
d6167a92
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
3 deletions
+27
-3
app/models/ci/runner.rb
app/models/ci/runner.rb
+4
-0
spec/models/ci/runner_spec.rb
spec/models/ci/runner_spec.rb
+23
-3
No files found.
app/models/ci/runner.rb
View file @
8dad45a8
...
@@ -146,6 +146,10 @@ module Ci
...
@@ -146,6 +146,10 @@ module Ci
runner_groups
.
any?
runner_groups
.
any?
end
end
def
project?
runner_projects
.
any?
end
def
can_pick?
(
build
)
def
can_pick?
(
build
)
return
false
if
self
.
ref_protected?
&&
!
build
.
protected?
return
false
if
self
.
ref_protected?
&&
!
build
.
protected?
...
...
spec/models/ci/runner_spec.rb
View file @
8dad45a8
...
@@ -660,9 +660,7 @@ describe Ci::Runner do
...
@@ -660,9 +660,7 @@ describe Ci::Runner do
describe
'group?'
do
describe
'group?'
do
it
'returns false when the runner is a project runner'
do
it
'returns false when the runner is a project runner'
do
project
=
create
:project
project
=
create
:project
runner
=
create
(
:ci_runner
,
description:
'Project runner'
).
tap
do
|
r
|
runner
=
create
:ci_runner
,
description:
'Project runner'
,
projects:
[
project
]
create
:ci_runner_project
,
runner:
r
,
project:
project
end
expect
(
runner
.
group?
).
to
be
false
expect
(
runner
.
group?
).
to
be
false
end
end
...
@@ -680,4 +678,26 @@ describe Ci::Runner do
...
@@ -680,4 +678,26 @@ describe Ci::Runner do
expect
(
runner
.
group?
).
to
be
true
expect
(
runner
.
group?
).
to
be
true
end
end
end
end
describe
'project?'
do
it
'returns false when the runner is a group prunner'
do
group
=
create
:group
runner
=
create
:ci_runner
,
description:
'Group runner'
,
groups:
[
group
]
expect
(
runner
.
project?
).
to
be
false
end
it
'returns false when the runner is a shared runner'
do
runner
=
create
:ci_runner
,
:shared
,
description:
'Shared runner'
expect
(
runner
.
project?
).
to
be
false
end
it
'returns true when the runner is assigned to a project'
do
project
=
create
:project
runner
=
create
:ci_runner
,
description:
'Group runner'
,
projects:
[
project
]
expect
(
runner
.
project?
).
to
be
true
end
end
end
end
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