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
|
@ -7,8 +7,8 @@ module Ci
|
||||||
end
|
end
|
||||||
|
|
||||||
def update(params)
|
def update(params)
|
||||||
runner.update(params).tap do
|
runner.update(params).tap do |updated|
|
||||||
runner.tick_runner_queue
|
runner.tick_runner_queue if updated
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,13 +6,36 @@ describe Ci::UpdateRunnerService, :services do
|
||||||
describe '#update' do
|
describe '#update' do
|
||||||
before do
|
before do
|
||||||
allow(runner).to receive(:tick_runner_queue)
|
allow(runner).to receive(:tick_runner_queue)
|
||||||
|
|
||||||
described_class.new(runner).update(description: 'new runner')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with description params' do
|
||||||
|
let(:params) { { description: 'new runner' } }
|
||||||
|
|
||||||
it 'updates the runner and ticking the queue' do
|
it 'updates the runner and ticking the queue' do
|
||||||
expect(runner.description).to eq('new runner')
|
expect(update).to be_truthy
|
||||||
|
|
||||||
|
runner.reload
|
||||||
|
|
||||||
expect(runner).to have_received(:tick_runner_queue)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue