File: ff_changes_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 (66 lines) | stat: -rw-r--r-- 1,760 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# frozen_string_literal: true

RSpec.describe QA::Tools::Ci::FfChanges do
  subject(:ff_changes) { described_class.new(mr_diff) }

  before do
    allow(Gitlab::QA::TestLogger).to receive(:logger).and_return(Logger.new(StringIO.new))
  end

  context "with merge request pipeline" do
    let(:deleted_file) { false }
    let(:mr_diff) do
      [
        {
          path: "config/feature_flags/development/async_commit_diff_files.yml",
          deleted_file: deleted_file
        }
      ]
    end

    before do
      allow(File).to receive(:read)
        .with(File.expand_path("../#{mr_diff.first[:path]}", QA::Runtime::Path.qa_root))
        .and_return(File.read("spec/fixtures/ff/async_commit_diff_files.yml"))
    end

    context "with changed feature flag" do
      it "returns inverse ff state option" do
        expect(ff_changes.fetch).to eq("async_commit_diff_files=enabled")
      end
    end

    context 'with feature flags outside of development and ops' do
      let(:mr_diff) do
        [
          {
            path: "config/feature_flags/gitlab_com_derisk/async_commit_diff_files.yml",
            deleted_filed: false
          }
        ]
      end

      it "returns inverse ff state option" do
        expect(ff_changes.fetch).to eq("async_commit_diff_files=enabled")
      end
    end

    context "with deleted feature flag" do
      let(:deleted_file) { true }

      it "returns deleted ff state option" do
        expect(ff_changes.fetch).to eq("async_commit_diff_files=deleted")
      end
    end
  end

  context "without merge request pipeline" do
    let(:mr_diff) { [] }

    context "with empty mr diff" do
      it "doesn't return any ff options" do
        expect(ff_changes.fetch).to be_nil
      end
    end
  end
end