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
Léo-Paul Géneau
gitlab-ce
Commits
9447e5c2
Commit
9447e5c2
authored
Feb 26, 2018
by
Alexis Reigel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extract method to adhere to "tell, don't ask"
parent
e13026a3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
1 deletion
+33
-1
app/models/ci/runner.rb
app/models/ci/runner.rb
+6
-0
app/services/ci/update_build_queue_service.rb
app/services/ci/update_build_queue_service.rb
+1
-1
spec/models/ci/runner_spec.rb
spec/models/ci/runner_spec.rb
+26
-0
No files found.
app/models/ci/runner.rb
View file @
9447e5c2
...
...
@@ -217,6 +217,12 @@ module Ci
end
end
def
invalidate_build_cache!
(
build
)
if
can_pick?
(
build
)
tick_runner_queue
end
end
private
def
cleanup_runner_queue
...
...
app/services/ci/update_build_queue_service.rb
View file @
9447e5c2
...
...
@@ -16,7 +16,7 @@ module Ci
def
tick_for
(
build
,
runners
)
runners
.
each
do
|
runner
|
runner
.
tick_runner_queue
if
runner
.
can_pick?
(
build
)
runner
.
invalidate_build_cache!
(
build
)
end
end
end
...
...
spec/models/ci/runner_spec.rb
View file @
9447e5c2
...
...
@@ -858,4 +858,30 @@ describe Ci::Runner do
end
end
end
describe
'#invalidate_build_cache!'
do
context
'runner can pick the build'
do
it
'calls #tick_runner_queue'
do
ci_build
=
build
:ci_build
runner
=
build
:ci_runner
allow
(
runner
).
to
receive
(
:can_pick?
).
with
(
ci_build
).
and_return
(
true
)
expect
(
runner
).
to
receive
(
:tick_runner_queue
)
runner
.
invalidate_build_cache!
(
ci_build
)
end
end
context
'runner cannot pick the build'
do
it
'does not call #tick_runner_queue'
do
ci_build
=
build
:ci_build
runner
=
build
:ci_runner
allow
(
runner
).
to
receive
(
:can_pick?
).
with
(
ci_build
).
and_return
(
false
)
expect
(
runner
).
not_to
receive
(
:tick_runner_queue
)
runner
.
invalidate_build_cache!
(
ci_build
)
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