Only tick queue if anything is updated
Feedback: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8664#note_22853522
This commit is contained in:
parent
105154aeae
commit
80bc66596a
2 changed files with 30 additions and 7 deletions
|
@ -7,8 +7,8 @@ module Ci
|
|||
end
|
||||
|
||||
def update(params)
|
||||
runner.update(params).tap do
|
||||
runner.tick_runner_queue
|
||||
runner.update(params).tap do |updated|
|
||||
runner.tick_runner_queue if updated
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,13 +6,36 @@ describe Ci::UpdateRunnerService, :services do
|
|||
describe '#update' do
|
||||
before do
|
||||
allow(runner).to receive(:tick_runner_queue)
|
||||
|
||||
described_class.new(runner).update(description: 'new runner')
|
||||
end
|
||||
|
||||
it 'updates the runner and ticking the queue' do
|
||||
expect(runner.description).to eq('new runner')
|
||||
expect(runner).to have_received(:tick_runner_queue)
|
||||
context 'with description params' do
|
||||
let(:params) { { description: 'new runner' } }
|
||||
|
||||
it 'updates the runner and ticking the queue' do
|
||||
expect(update).to be_truthy
|
||||
|
||||
runner.reload
|
||||
|
||||
expect(runner).to have_received(:tick_runner_queue)
|
||||
expect(runner.description).to eq('new runner')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when params are not valid' do
|
||||
let(:params) { { run_untagged: false } }
|
||||
|
||||
it 'does not update and give false because it is not valid' do
|
||||
expect(update).to be_falsey
|
||||
|
||||
runner.reload
|
||||
|
||||
expect(runner).not_to have_received(:tick_runner_queue)
|
||||
expect(runner.run_untagged).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
described_class.new(runner).update(params)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue