extract method to adhere to "tell, don't ask"
This commit is contained in:
parent
e13026a378
commit
9447e5c27d
3 changed files with 33 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue