Commit 80bc6659 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Only tick queue if anything is updated

Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8664#note_22853522
parent 105154ae
...@@ -7,8 +7,8 @@ module Ci ...@@ -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 ...@@ -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)
end
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
described_class.new(runner).update(description: 'new runner') expect(runner).not_to have_received(:tick_runner_queue)
expect(runner.run_untagged).to be_truthy
end
end end
it 'updates the runner and ticking the queue' do def update
expect(runner.description).to eq('new runner') described_class.new(runner).update(params)
expect(runner).to have_received(:tick_runner_queue)
end end
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