Skip to content
Snippets Groups Projects
Commit 80bc6659 authored by Lin Jen-Shin's avatar Lin Jen-Shin
Browse files

Only tick queue if anything is updated

parent 105154ae
Branches
Tags
1 merge request!8664Prefer service object over after_save hook
Pipeline #
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
 
context 'with description params' do
let(:params) { { description: 'new runner' } }
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.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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment