diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /spec/rubocop/cop/gitlab | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'spec/rubocop/cop/gitlab')
-rw-r--r-- | spec/rubocop/cop/gitlab/bulk_insert_spec.rb | 12 | ||||
-rw-r--r-- | spec/rubocop/cop/gitlab/json_spec.rb | 15 | ||||
-rw-r--r-- | spec/rubocop/cop/gitlab/mark_used_feature_flags_spec.rb | 6 |
3 files changed, 25 insertions, 8 deletions
diff --git a/spec/rubocop/cop/gitlab/bulk_insert_spec.rb b/spec/rubocop/cop/gitlab/bulk_insert_spec.rb index 7c60518f890..bbc8f381d01 100644 --- a/spec/rubocop/cop/gitlab/bulk_insert_spec.rb +++ b/spec/rubocop/cop/gitlab/bulk_insert_spec.rb @@ -6,17 +6,17 @@ require_relative '../../../../rubocop/cop/gitlab/bulk_insert' RSpec.describe RuboCop::Cop::Gitlab::BulkInsert do subject(:cop) { described_class.new } - it 'flags the use of Gitlab::Database.bulk_insert' do + it 'flags the use of Gitlab::Database.main.bulk_insert' do expect_offense(<<~SOURCE) - Gitlab::Database.bulk_insert('merge_request_diff_files', rows) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use the `BulkInsertSafe` concern, [...] + Gitlab::Database.main.bulk_insert('merge_request_diff_files', rows) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use the `BulkInsertSafe` concern, [...] SOURCE end - it 'flags the use of ::Gitlab::Database.bulk_insert' do + it 'flags the use of ::Gitlab::Database.main.bulk_insert' do expect_offense(<<~SOURCE) - ::Gitlab::Database.bulk_insert('merge_request_diff_files', rows) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use the `BulkInsertSafe` concern, [...] + ::Gitlab::Database.main.bulk_insert('merge_request_diff_files', rows) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use the `BulkInsertSafe` concern, [...] SOURCE end end diff --git a/spec/rubocop/cop/gitlab/json_spec.rb b/spec/rubocop/cop/gitlab/json_spec.rb index 66b2c675e80..7998f26da4e 100644 --- a/spec/rubocop/cop/gitlab/json_spec.rb +++ b/spec/rubocop/cop/gitlab/json_spec.rb @@ -6,7 +6,7 @@ require_relative '../../../../rubocop/cop/gitlab/json' RSpec.describe RuboCop::Cop::Gitlab::Json do subject(:cop) { described_class.new } - context 'when JSON is called' do + context 'when ::JSON is called' do it 'registers an offense' do expect_offense(<<~RUBY) class Foo @@ -18,4 +18,17 @@ RSpec.describe RuboCop::Cop::Gitlab::Json do RUBY end end + + context 'when ActiveSupport::JSON is called' do + it 'registers an offense' do + expect_offense(<<~RUBY) + class Foo + def bar + ActiveSupport::JSON.parse('{ "foo": "bar" }') + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Avoid calling `JSON` directly. [...] + end + end + RUBY + end + end end diff --git a/spec/rubocop/cop/gitlab/mark_used_feature_flags_spec.rb b/spec/rubocop/cop/gitlab/mark_used_feature_flags_spec.rb index 968cafc57d4..35b21477d80 100644 --- a/spec/rubocop/cop/gitlab/mark_used_feature_flags_spec.rb +++ b/spec/rubocop/cop/gitlab/mark_used_feature_flags_spec.rb @@ -194,6 +194,10 @@ RSpec.describe RuboCop::Cop::Gitlab::MarkUsedFeatureFlags do include_examples 'sets flag as used', 'self.limit_feature_flag = :foo', 'foo' end + describe 'self.limit_feature_flag_for_override = :foo' do + include_examples 'sets flag as used', 'self.limit_feature_flag_for_override = :foo', 'foo' + end + describe 'FEATURE_FLAG = :foo' do include_examples 'sets flag as used', 'FEATURE_FLAG = :foo', 'foo' end @@ -218,7 +222,7 @@ RSpec.describe RuboCop::Cop::Gitlab::MarkUsedFeatureFlags do include_examples 'does not set any flags as used', 'field :solution' include_examples 'does not set any flags as used', 'field :runners, Types::Ci::RunnerType.connection_type' include_examples 'does not set any flags as used', 'field :runners, Types::Ci::RunnerType.connection_type, null: true, description: "hello world"' - include_examples 'does not set any flags as used', 'field :solution, type: GraphQL::STRING_TYPE, null: true, description: "URL to the vulnerabilitys details page."' + include_examples 'does not set any flags as used', 'field :solution, type: GraphQL::Types::String, null: true, description: "URL to the vulnerabilitys details page."' end describe "tracking of usage data metrics known events happens at the beginning of inspection" do |