Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
60aaff3b
Commit
60aaff3b
authored
Feb 14, 2022
by
Robert May
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable Grape/Gitlab::Json hook
Changelog: performance
parent
f536b8cd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
43 deletions
+6
-43
config/feature_flags/development/grape_gitlab_json.yml
config/feature_flags/development/grape_gitlab_json.yml
+0
-8
lib/gitlab/json.rb
lib/gitlab/json.rb
+1
-8
spec/lib/gitlab/json_spec.rb
spec/lib/gitlab/json_spec.rb
+5
-27
No files found.
config/feature_flags/development/grape_gitlab_json.yml
deleted
100644 → 0
View file @
f536b8cd
---
name
:
grape_gitlab_json
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/36472
rollout_issue_url
:
milestone
:
'
13.2'
type
:
development
group
:
group::source code
default_enabled
:
true
lib/gitlab/json.rb
View file @
60aaff3b
...
...
@@ -180,9 +180,6 @@ module Gitlab
class
GrapeFormatter
# Convert an object to JSON.
#
# This will default to the built-in Grape formatter if either :oj_json or :grape_gitlab_json
# flags are disabled.
#
# The `env` param is ignored because it's not needed in either our formatter or Grape's,
# but it is passed through for consistency.
#
...
...
@@ -194,11 +191,7 @@ module Gitlab
def
self
.
call
(
object
,
env
=
nil
)
return
object
.
to_s
if
object
.
is_a?
(
PrecompiledJson
)
if
Feature
.
enabled?
(
:grape_gitlab_json
,
default_enabled:
true
)
Gitlab
::
Json
.
dump
(
object
)
else
Grape
::
Formatter
::
Json
.
call
(
object
,
env
)
end
Gitlab
::
Json
.
dump
(
object
)
end
end
...
...
spec/lib/gitlab/json_spec.rb
View file @
60aaff3b
...
...
@@ -317,36 +317,14 @@ RSpec.describe Gitlab::Json do
let
(
:env
)
{
{}
}
let
(
:result
)
{
"{
\"
test
\"
:true}"
}
context
"grape_gitlab_json flag is enabled"
do
before
do
stub_feature_flags
(
grape_gitlab_json:
true
)
end
it
"generates JSON"
do
expect
(
subject
).
to
eq
(
result
)
end
it
"uses Gitlab::Json"
do
expect
(
Gitlab
::
Json
).
to
receive
(
:dump
).
with
(
obj
)
subject
end
it
"generates JSON"
do
expect
(
subject
).
to
eq
(
result
)
end
context
"grape_gitlab_json flag is disabled"
do
before
do
stub_feature_flags
(
grape_gitlab_json:
false
)
end
it
"uses Gitlab::Json"
do
expect
(
Gitlab
::
Json
).
to
receive
(
:dump
).
with
(
obj
)
it
"generates JSON"
do
expect
(
subject
).
to
eq
(
result
)
end
it
"uses Grape::Formatter::Json"
do
expect
(
Grape
::
Formatter
::
Json
).
to
receive
(
:call
).
with
(
obj
,
env
)
subject
end
subject
end
context
"precompiled JSON"
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment