2019-04-11 08:17:24 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-01-20 08:57:01 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 02:09:01 -04:00
|
|
|
RSpec.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
|
|
|
|
|
2020-04-21 11:21:10 -04:00
|
|
|
context 'with cost factor params' do
|
|
|
|
let(:params) { { public_projects_minutes_cost_factor: 1.1, private_projects_minutes_cost_factor: 2.2 }}
|
|
|
|
|
|
|
|
it 'updates the runner cost factors' do
|
|
|
|
expect(update).to be_truthy
|
|
|
|
|
|
|
|
runner.reload
|
|
|
|
|
|
|
|
expect(runner.public_projects_minutes_cost_factor).to eq(1.1)
|
|
|
|
expect(runner.private_projects_minutes_cost_factor).to eq(2.2)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-02-06 14:05:19 -05:00
|
|
|
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
|
2020-09-07 14:08:32 -04:00
|
|
|
described_class.new(runner).update(params) # rubocop: disable Rails/SaveBang
|
2017-01-20 08:57:01 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|