BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
8d61d33d
Unverified
Commit
8d61d33d
authored
Oct 04, 2017
by
Alexis Reigel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use .owned_or_shared for #assignable_for?
instead of having the explicit logic duplicated from the scope we can use the scope instead.
parent
d588adff
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
4 deletions
+22
-4
runner.rb
app/models/ci/runner.rb
+1
-1
runner_spec.rb
spec/models/ci/runner_spec.rb
+21
-3
No files found.
app/models/ci/runner.rb
View file @
8d61d33d
...
@@ -227,7 +227,7 @@ module Ci
...
@@ -227,7 +227,7 @@ module Ci
end
end
def
assignable_for?
(
project_id
)
def
assignable_for?
(
project_id
)
is_shared?
||
projects
.
exists?
(
id:
project_id
)
self
.
class
.
owned_or_shared
(
project_id
).
where
(
id:
self
.
id
).
any?
end
end
def
accepting_tags?
(
build
)
def
accepting_tags?
(
build
)
...
...
spec/models/ci/runner_spec.rb
View file @
8d61d33d
...
@@ -236,6 +236,13 @@ describe Ci::Runner do
...
@@ -236,6 +236,13 @@ describe Ci::Runner do
build
.
project
.
runners
<<
runner
build
.
project
.
runners
<<
runner
end
end
context
'a different runner'
do
it
'cannot handle builds'
do
other_runner
=
create
:ci_runner
expect
(
other_runner
.
can_pick?
(
build
)).
to
be_falsey
end
end
context
'when runner does not have tags'
do
context
'when runner does not have tags'
do
it
'can handle builds without tags'
do
it
'can handle builds without tags'
do
expect
(
runner
.
can_pick?
(
build
)).
to
be_truthy
expect
(
runner
.
can_pick?
(
build
)).
to
be_truthy
...
@@ -277,7 +284,7 @@ describe Ci::Runner do
...
@@ -277,7 +284,7 @@ describe Ci::Runner do
context
'when runner cannot pick untagged jobs'
do
context
'when runner cannot pick untagged jobs'
do
before
do
before
do
runner
.
run_untagged
=
false
runner
.
update_attributes!
(
run_untagged:
false
)
end
end
it
'cannot handle builds without tags'
do
it
'cannot handle builds without tags'
do
...
@@ -290,7 +297,7 @@ describe Ci::Runner do
...
@@ -290,7 +297,7 @@ describe Ci::Runner do
context
'when runner is shared'
do
context
'when runner is shared'
do
before
do
before
do
runner
.
is_shared
=
true
runner
.
update_attributes!
(
is_shared:
true
)
build
.
project
.
runners
=
[]
build
.
project
.
runners
=
[]
end
end
...
@@ -300,7 +307,7 @@ describe Ci::Runner do
...
@@ -300,7 +307,7 @@ describe Ci::Runner do
context
'when runner is locked'
do
context
'when runner is locked'
do
before
do
before
do
runner
.
locked
=
true
runner
.
update_attributes!
(
locked:
true
)
end
end
it
'can handle builds'
do
it
'can handle builds'
do
...
@@ -325,6 +332,17 @@ describe Ci::Runner do
...
@@ -325,6 +332,17 @@ describe Ci::Runner do
expect
(
runner
.
can_pick?
(
build
)).
to
be_falsey
expect
(
runner
.
can_pick?
(
build
)).
to
be_falsey
end
end
end
end
context
'when runner is assigned to a group'
do
before
do
build
.
project
.
runners
=
[]
runner
.
groups
<<
create
(
:group
,
projects:
[
build
.
project
])
end
it
'can handle builds'
do
expect
(
runner
.
can_pick?
(
build
)).
to
be_truthy
end
end
end
end
context
'when access_level of runner is not_protected'
do
context
'when access_level of runner is not_protected'
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