diff --git a/app/services/ci/update_runner_service.rb b/app/services/ci/update_runner_service.rb index 198b29b3a9d..450ee7da1c9 100644 --- a/app/services/ci/update_runner_service.rb +++ b/app/services/ci/update_runner_service.rb @@ -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 diff --git a/spec/services/ci/update_runner_service_spec.rb b/spec/services/ci/update_runner_service_spec.rb index 41372476228..e429fcfc72f 100644 --- a/spec/services/ci/update_runner_service_spec.rb +++ b/spec/services/ci/update_runner_service_spec.rb @@ -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