Welcome to mirror list, hosted at ThFree Co, Russian Federation.

update_worker_spec.rb « canary_ingress « environments « workers « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7bc5108719c8b466c16fe0844c6fdc8ec9cdc872 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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