File: activate_integration_worker_spec.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (52 lines) | stat: -rw-r--r-- 1,885 bytes parent folder | download
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Clusters::Applications::ActivateIntegrationWorker, '#perform', feature_category: :deployment_management do
  context 'when cluster exists' do
    describe 'prometheus integration' do
      let(:integration_name) { 'prometheus' }

      before do
        create(:clusters_integrations_prometheus, cluster: cluster)
      end

      context 'with cluster type: group' do
        let(:group) { create(:group) }
        let(:project) { create(:project, group: group) }
        let(:cluster) { create(:cluster_for_group, groups: [group]) }

        it 'ensures Prometheus integration is activated' do
          expect { described_class.new.perform(cluster.id, integration_name) }
            .to change { project.reload.prometheus_integration&.active }.from(nil).to(true)
        end
      end

      context 'with cluster type: project' do
        let(:project) { create(:project) }
        let(:cluster) { create(:cluster, projects: [project]) }

        it 'ensures Prometheus integration is activated' do
          expect { described_class.new.perform(cluster.id, integration_name) }
            .to change { project.reload.prometheus_integration&.active }.from(nil).to(true)
        end
      end

      context 'with cluster type: instance' do
        let(:project) { create(:project) }
        let(:cluster) { create(:cluster, :instance) }

        it 'ensures Prometheus integration is activated' do
          expect { described_class.new.perform(cluster.id, integration_name) }
            .to change { project.reload.prometheus_integration&.active }.from(nil).to(true)
        end
      end
    end
  end

  context 'when cluster does not exist' do
    it 'does not raise Record Not Found error' do
      expect { described_class.new.perform(0, 'ignored in this context') }.not_to raise_error
    end
  end
end