Commit 9447e5c2 authored by Alexis Reigel's avatar Alexis Reigel

extract method to adhere to "tell, don't ask"

parent e13026a3
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment