2019-04-11 08:17:24 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-01-20 08:57:01 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 10:24:02 -04:00
|
|
|
describe Ci::UpdateRunnerService do
|
2017-01-20 08:57:01 -05:00
|
|
|
let(:runner) { create(:ci_runner) }
|
|
|
|
|
|
|
|
describe '#update' do
|
|
|
|
before do
|
|
|
|
allow(runner).to receive(:tick_runner_queue)
|
2017-02-06 14:05:19 -05:00
|
|
|
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
|
2017-01-20 08:57:01 -05:00
|
|
|
|
2017-02-06 14:05:19 -05:00
|
|
|
expect(runner).not_to have_received(:tick_runner_queue)
|
|
|
|
expect(runner.run_untagged).to be_truthy
|
|
|
|
end
|
2017-01-20 08:57:01 -05:00
|
|
|
end
|
|
|
|
|
2017-02-06 14:05:19 -05:00
|
|
|
def update
|
|
|
|
described_class.new(runner).update(params)
|
2017-01-20 08:57:01 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|