diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2017-02-17 13:03:12 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2017-02-17 13:03:12 +0000 |
commit | f662bc5a866dc24580caa48952f25061bae60d1a (patch) | |
tree | 1cd3c637b0581056aa9ce608e08b974e870a4607 /spec/services | |
parent | 5cc9ebbe14ce35de1ec45fc7abce3aa9f408ddf2 (diff) | |
parent | 60288d6c62d7e65ed5a93a72ba047ccaa2daa22b (diff) | |
download | gitlab-ce-f662bc5a866dc24580caa48952f25061bae60d1a.tar.gz |
Merge branch 'use-update-runner-service' into 'master'
Prefer service object over after_save hook
Closes #26921
See merge request !8664
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/ci/update_runner_service_spec.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/services/ci/update_runner_service_spec.rb b/spec/services/ci/update_runner_service_spec.rb new file mode 100644 index 00000000000..e429fcfc72f --- /dev/null +++ b/spec/services/ci/update_runner_service_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +describe Ci::UpdateRunnerService, :services do + let(:runner) { create(:ci_runner) } + + describe '#update' do + before do + 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 + + 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 |