blob: b3864c5495ff95cac6e5f76f59920297f6dcd4fc (
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
|
# 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?
Gitlab::Saas.enabled?
::Gitlab::Saas.enabled?
]
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
|