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

avoid_gitlab_instance_checks_spec.rb « gitlab « cop « rubocop « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2dba6194d44ba29e229e99bf349014ac4098a80f (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
# frozen_string_literal: true

require 'rubocop_spec_helper'
require 'rspec-parameterized'
require_relative '../../../../rubocop/cop/gitlab/avoid_gitlab_instance_checks'

RSpec.describe RuboCop::Cop::Gitlab::AvoidGitlabInstanceChecks, feature_category: :shared do
  let(:msg) { described_class::MSG }

  describe 'bad examples' do
    where(:code) do
      %w[
        Gitlab.com?
        Gitlab.com_except_jh?
        Gitlab.com_and_canary?
        Gitlab.com_but_not_canary?
        Gitlab.org_or_com?
        ::Gitlab.com?
        Gitlab::CurrentSettings.should_check_namespace_plan?
        ::Gitlab::CurrentSettings.should_check_namespace_plan?
      ]
    end

    with_them do
      it 'registers an offense' do
        expect_offense(<<~CODE, node: code)
          return if %{node}
                    ^{node} Avoid the use of [...]
        CODE
      end
    end
  end

  describe 'good examples' do
    where(:code) do
      %w[com? com Gitlab.com Gitlab::CurrentSettings.check_namespace_plan?]
    end

    with_them do
      it 'does not register an offense' do
        expect_no_offenses(code)
      end
    end
  end
end