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

20240116211138_update_max_code_indexing_concurrency_in_application_settings_for_gitlab_com_spec.rb « migrations « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8bed7e1b8a17018e07d091a5ae26e201ab39aafc (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
47
48
# frozen_string_literal: true

require 'spec_helper'
require_migration!

RSpec.describe UpdateMaxCodeIndexingConcurrencyInApplicationSettingsForGitlabCom, feature_category: :global_search do
  let(:settings) { table(:application_settings) }

  describe "#up" do
    subject(:up) { migrate! }

    it 'does nothing when not in gitlab.com' do
      record = settings.create!

      expect { up }.not_to change { record.reload.elasticsearch_max_code_indexing_concurrency }
    end

    it 'updates elasticsearch_worker_number_of_shards when gitlab.com' do
      allow(Gitlab).to receive(:com?).and_return(true)

      record = settings.create!

      expect { up }.to change { record.reload.elasticsearch_max_code_indexing_concurrency }.from(30).to(60)
    end
  end

  describe "#down" do
    subject(:down) { schema_migrate_down! }

    it 'does nothing when not in gitlab.com' do
      record = settings.create!(elasticsearch_max_code_indexing_concurrency: 60)

      migrate!

      expect { down }.not_to change { record.reload.elasticsearch_max_code_indexing_concurrency }
    end

    it 'updates elasticsearch_worker_number_of_shards when gitlab.com' do
      allow(Gitlab).to receive(:com?).and_return(true)

      record = settings.create!(elasticsearch_max_code_indexing_concurrency: 60)

      migrate!

      expect { down }.to change { record.reload.elasticsearch_max_code_indexing_concurrency }.from(60).to(30)
    end
  end
end