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-11-03 21:11:17 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-11-03 21:11:17 +0300
commit44434461b3c58336624125b5ab002e7200e4a208 (patch)
treecef2ea602e94abd9c1ef6ee77b6988c4c85475b7 /spec/rubocop
parente6fa9529b4922a4c552e8908a2929ff995e8b53d (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/rubocop')
-rw-r--r--spec/rubocop/cop/gitlab/json_spec.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/rubocop/cop/gitlab/json_spec.rb b/spec/rubocop/cop/gitlab/json_spec.rb
index bf0acaf0498..7a7982b2404 100644
--- a/spec/rubocop/cop/gitlab/json_spec.rb
+++ b/spec/rubocop/cop/gitlab/json_spec.rb
@@ -25,6 +25,27 @@ RSpec.describe RuboCop::Cop::Gitlab::Json do
end
end
+ context 'when ::JSON is called in EE' do
+ it 'registers an offense and autocorrects' do
+ expect_offense(<<~RUBY, '/path/to/ee/foo.rb')
+ class Foo
+ def bar
+ JSON.parse('{ "foo": "bar" }')
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `Gitlab::Json` over calling `JSON` or `to_json` directly. [...]
+ end
+ end
+ RUBY
+
+ expect_correction(<<~RUBY)
+ class Foo
+ def bar
+ ::Gitlab::Json.parse('{ "foo": "bar" }')
+ end
+ end
+ RUBY
+ end
+ end
+
context 'when ActiveSupport::JSON is called' do
it 'registers an offense and autocorrects' do
expect_offense(<<~RUBY)