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

search_archived_filter_shared_examples.rb « gitlab « lib « shared_examples « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ac72b31d5a4e152683f3d3e5bb2a7de4c2b45e41 (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
49
50
51
52
53
54
55
56
57
58
59
60
# frozen_string_literal: true

RSpec.shared_examples 'search results filtered by archived' do |feature_flag_name, migration_name|
  context 'when filter not provided (all behavior)' do
    let(:filters) { {} }

    it 'returns unarchived results only' do
      expect(results.objects(scope)).to include unarchived_result
      expect(results.objects(scope)).not_to include archived_result
    end
  end

  context 'when include_archived is true' do
    let(:filters) { { include_archived: true } }

    it 'returns archived and unarchived results' do
      expect(results.objects(scope)).to include unarchived_result
      expect(results.objects(scope)).to include archived_result
    end
  end

  context 'when include_archived filter is false' do
    let(:filters) { { include_archived: false } }

    it 'returns unarchived results only' do
      expect(results.objects(scope)).to include unarchived_result
      expect(results.objects(scope)).not_to include archived_result
    end
  end

  if feature_flag_name.present?
    context "when the #{feature_flag_name} feature flag is disabled" do
      let(:filters) { {} }

      before do
        stub_feature_flags("#{feature_flag_name}": false)
      end

      it 'returns archived and unarchived results' do
        expect(results.objects(scope)).to include unarchived_result
        expect(results.objects(scope)).to include archived_result
      end
    end
  end

  if migration_name.present?
    context "when the #{migration_name} is not completed" do
      let(:filters) { {} }

      before do
        set_elasticsearch_migration_to(migration_name.to_s, including: false)
      end

      it 'returns archived and unarchived results' do
        expect(results.objects(scope)).to include unarchived_result
        expect(results.objects(scope)).to include archived_result
      end
    end
  end
end