diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2024-01-04 06:14:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2024-01-04 06:14:51 +0300 |
commit | 73270622cc7b3e40c019f3b1aad7ebfa2c224ba0 (patch) | |
tree | eaee70f3b108d254bf16a6847d4e8724f1fbd18c /spec/rubocop | |
parent | 54efc4fee638a0f47372961b24c0efa477e5b01a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/rubocop')
-rw-r--r-- | spec/rubocop/cop/gitlab/license_available_usage_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/rubocop/cop/gitlab/license_available_usage_spec.rb b/spec/rubocop/cop/gitlab/license_available_usage_spec.rb new file mode 100644 index 00000000000..230224e8e53 --- /dev/null +++ b/spec/rubocop/cop/gitlab/license_available_usage_spec.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require 'rubocop_spec_helper' +require 'rspec-parameterized' +require_relative '../../../../rubocop/cop/gitlab/license_available_usage' + +RSpec.describe RuboCop::Cop::Gitlab::LicenseAvailableUsage, feature_category: :shared do + let(:msg) { described_class::MSG } + + describe 'uses license check' do + it 'registers an offense' do + expect_offense(<<~SOURCE) + License.feature_available?(:elastic_search) && super + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Avoid License.feature_available? usage in ApplicationSetting due to possible cyclical dependency issue. For more information see: https://gitlab.com/gitlab-org/gitlab/-/issues/423237 + SOURCE + end + end + + describe 'no license check' do + let(:source) do + <<~RUBY + class C + def check_without_license_usage? + test?(:feature) + end + end + RUBY + end + + it 'does not register an offense' do + expect_no_offenses(source) + end + end +end |