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>2022-12-16 06:07:09 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-12-16 06:07:09 +0300
commit2805579d338811be87ef7e707a377ad7ec73fe21 (patch)
treea90a5b4b0a7c930fe56dddd5560123fd81a0c5e4 /spec/rubocop
parentbfa34fc19c0f74dbbf7caa3063565ec77efe0999 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/rubocop')
-rw-r--r--spec/rubocop/cop/feature_flag_usage_spec.rb55
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/rubocop/cop/feature_flag_usage_spec.rb b/spec/rubocop/cop/feature_flag_usage_spec.rb
new file mode 100644
index 00000000000..13f58ca7084
--- /dev/null
+++ b/spec/rubocop/cop/feature_flag_usage_spec.rb
@@ -0,0 +1,55 @@
+# frozen_string_literal: true
+
+require 'rubocop_spec_helper'
+
+require_relative '../../../rubocop/cop/feature_flag_usage'
+
+RSpec.describe RuboCop::Cop::FeatureFlagUsage, feature_category: :scalability do
+ let(:msg) { described_class::MSG }
+
+ context 'when calling Feature.enabled?' do
+ it 'registers offence' do
+ expect_offense(<<~PATTERN)
+ Feature.enabled?(:fflag)
+ ^^^^^^^^^^^^^^^^^^^^^^^^ #{msg}
+ PATTERN
+ end
+
+ it 'registers offence when called with type parameter' do
+ expect_offense(<<~PATTERN)
+ Feature.enabled?(:fflag, type: :ops)
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #{msg}
+ PATTERN
+ end
+
+ it 'registers offence when called under global namespace' do
+ expect_offense(<<~PATTERN)
+ ::Feature.enabled?(:fflag, type: :ops)
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #{msg}
+ PATTERN
+ end
+ end
+
+ context 'when calling Feature.disabled?' do
+ it 'registers offence' do
+ expect_offense(<<~PATTERN)
+ Feature.disabled?(:fflag)
+ ^^^^^^^^^^^^^^^^^^^^^^^^^ #{msg}
+ PATTERN
+ end
+
+ it 'registers offence when called with type parameter' do
+ expect_offense(<<~PATTERN)
+ Feature.disabled?(:fflag, type: :ops)
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #{msg}
+ PATTERN
+ end
+
+ it 'registers offence when called under global namespace' do
+ expect_offense(<<~PATTERN)
+ ::Feature.disabled?(:fflag, type: :ops)
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #{msg}
+ PATTERN
+ end
+ end
+end