File: multiversion_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 (79 lines) | stat: -rw-r--r-- 2,713 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
67
68
69
70
71
72
73
74
75
76
77
78
79
# frozen_string_literal: true

require 'rspec-parameterized'
require 'fast_spec_helper'
require 'gitlab/dangerfiles/spec_helper'

require_relative '../../../tooling/danger/multiversion'
require_relative '../../../tooling/danger/project_helper'

RSpec.describe Tooling::Danger::Multiversion, feature_category: :shared do
  include_context "with dangerfile"

  subject(:multiversion) { fake_danger.new(helper: fake_helper, git: fake_git) }

  let(:fake_danger) { DangerSpecHelper.fake_danger.include(described_class) }
  let(:ci_env) { true }

  before do
    allow(fake_helper).to receive(:ci?).and_return(ci_env)
    allow(fake_git).to receive(:modified_files).and_return(modified_files)
    allow(fake_git).to receive(:added_files).and_return(added_files)
  end

  describe '#check!' do
    using RSpec::Parameterized::TableSyntax

    context 'when not in ci environment' do
      let(:ci_env) { false }

      it 'does not add the warning markdown section' do
        expect(multiversion).not_to receive(:markdown)

        multiversion.check!
      end
    end

    context 'when GraphQL API and frontend assets have not been simultaneously updated' do
      where(:modified_files, :added_files) do
        %w[app/assets/helloworld.vue]     | %w[]
        %w[app/assets/helloworld.vue]     | %w[app/type.rb]
        %w[app/assets/helloworld.js]      | %w[app/graphql.rb]
        %w[app/assets/helloworld.graphql] | %w[app/models/graphql.rb]
        %w[]                              | %w[app/graphql/type.rb]
        %w[app/vue.txt] | %w[app/graphql/type.rb]
        %w[app/views/foo.haml] | %w[app/graphql/type.rb]
        %w[foo] | %w[]
        %w[] | %w[]
      end

      with_them do
        it 'does not add the warning markdown section' do
          expect(multiversion).not_to receive(:markdown)

          multiversion.check!
        end
      end
    end

    context 'when GraphQL API and frontend assets have been simultaneously updated' do
      where(:modified_files, :added_files) do
        %w[app/assets/helloworld.vue]        | %w[app/graphql/type.rb]
        %w[app/assets/helloworld.vue]        | %w[app/graphql/type.rb]
        %w[app/assets/helloworld.js]         | %w[app/graphql/type.rb]
        %w[ee/app/assets/helloworld.js]      | %w[app/graphql/type.rb]
        %w[app/assets/helloworld.graphql]    | %w[ee/app/graphql/type.rb]
        %w[ee/app/assets/helloworld.graphql] | %w[ee/app/graphql/type.rb]
        %w[ee/app/assets/helloworld.graphql] | %w[jh/app/graphql/type.rb]
      end

      with_them do
        it 'adds the warning markdown section' do
          expect(multiversion).to receive(:markdown)

          multiversion.check!
        end
      end
    end
  end
end