diff options
Diffstat (limited to 'spec/workers/environments/canary_ingress/update_worker_spec.rb')
-rw-r--r-- | spec/workers/environments/canary_ingress/update_worker_spec.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/workers/environments/canary_ingress/update_worker_spec.rb b/spec/workers/environments/canary_ingress/update_worker_spec.rb new file mode 100644 index 00000000000..7bc5108719c --- /dev/null +++ b/spec/workers/environments/canary_ingress/update_worker_spec.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Environments::CanaryIngress::UpdateWorker do + let_it_be(:environment) { create(:environment) } + let(:worker) { described_class.new } + + describe '#perform' do + subject { worker.perform(environment_id, params) } + + let(:environment_id) { environment.id } + let(:params) { { 'weight' => 50 } } + + it 'executes the update service' do + expect_next_instance_of(Environments::CanaryIngress::UpdateService, environment.project, nil, params) do |service| + expect(service).to receive(:execute).with(environment) + end + + subject + end + + context 'when an environment does not exist' do + let(:environment_id) { non_existing_record_id } + + it 'does not execute the update service' do + expect(Environments::CanaryIngress::UpdateService).not_to receive(:new) + + subject + end + end + end +end |