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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-10-05 21:09:33 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-10-05 21:09:33 +0300
commitc20e6edd8a648a2cecb7ba0c4e8be48ce68e25a1 (patch)
tree804cbc1984f4b6636d958bf7b70a00f323a8137f /spec/rubocop
parent3e6c042eb05e09d88c2bd988cb9ef5f9eba67794 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/rubocop')
-rw-r--r--spec/rubocop/cop/gitlab/avoid_gitlab_instance_checks_spec.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/rubocop/cop/gitlab/avoid_gitlab_instance_checks_spec.rb b/spec/rubocop/cop/gitlab/avoid_gitlab_instance_checks_spec.rb
new file mode 100644
index 00000000000..2dba6194d44
--- /dev/null
+++ b/spec/rubocop/cop/gitlab/avoid_gitlab_instance_checks_spec.rb
@@ -0,0 +1,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