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

20230428085332_remove_shimo_zentao_integration_records_spec.rb « migrations « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1d2fbb6b95dd90ef14fc1d3bb242e6c06a36c999 (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
34
35
36
37
38
39
40
41
42
43
44
45
46
# frozen_string_literal: true

require 'spec_helper'

require_migration!

RSpec.describe RemoveShimoZentaoIntegrationRecords, feature_category: :integrations do
  let(:integrations) { table(:integrations) }
  let(:zentao_tracker_data) { table(:zentao_tracker_data) }

  before do
    integrations.create!(id: 1, type_new: 'Integrations::MockMonitoring')
    integrations.create!(id: 2, type_new: 'Integrations::Redmine')
    integrations.create!(id: 3, type_new: 'Integrations::Confluence')

    integrations.create!(id: 4, type_new: 'Integrations::Shimo')
    integrations.create!(id: 5, type_new: 'Integrations::Zentao')
    integrations.create!(id: 6, type_new: 'Integrations::Zentao')
    zentao_tracker_data.create!(id: 1, integration_id: 5)
    zentao_tracker_data.create!(id: 2, integration_id: 6)
  end

  context 'with CE/EE env' do
    it 'destroys all shimo and zentao integrations' do
      migrate!

      expect(integrations.count).to eq(3) # keep other integrations
      expect(integrations.where(type_new: described_class::TYPES).count).to eq(0)
      expect(zentao_tracker_data.count).to eq(0)
    end
  end

  context 'with JiHu env' do
    before do
      allow(Gitlab).to receive(:jh?).and_return(true)
    end

    it 'keeps shimo and zentao integrations' do
      migrate!

      expect(integrations.count).to eq(6)
      expect(integrations.where(type_new: described_class::TYPES).count).to eq(3)
      expect(zentao_tracker_data.count).to eq(2)
    end
  end
end