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
a379ab20
Commit
a379ab20
authored
Feb 27, 2021
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix outstanding rubocop violations in BaseField
These were discovered using REVEAL_RUBOCOP_TODO
parent
3b96d441
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
11 deletions
+18
-11
app/graphql/types/base_field.rb
app/graphql/types/base_field.rb
+8
-4
spec/graphql/gitlab_schema_spec.rb
spec/graphql/gitlab_schema_spec.rb
+10
-7
No files found.
app/graphql/types/base_field.rb
View file @
a379ab20
...
...
@@ -54,8 +54,10 @@ module Types
end
def
check_feature_flag
(
args
)
args
[
:description
]
=
feature_documentation_message
(
args
[
:feature_flag
],
args
[
:description
])
if
args
[
:feature_flag
].
present?
args
.
delete
(
:feature_flag
)
ff
=
args
.
delete
(
:feature_flag
)
return
args
unless
ff
.
present?
args
[
:description
]
=
feature_documentation_message
(
ff
,
args
[
:description
])
args
end
...
...
@@ -78,7 +80,9 @@ module Types
# items which can be loaded.
proc
do
|
ctx
,
args
,
child_complexity
|
# Resolvers may add extra complexity depending on used arguments
complexity
=
child_complexity
+
self
.
resolver
&
.
try
(
:resolver_complexity
,
args
,
child_complexity:
child_complexity
).
to_i
complexity
=
child_complexity
+
resolver
&
.
try
(
:resolver_complexity
,
args
,
child_complexity:
child_complexity
).
to_i
complexity
+=
1
if
calls_gitaly?
complexity
+=
complexity
*
connection_complexity_multiplier
(
ctx
,
args
)
...
...
@@ -93,7 +97,7 @@ module Types
page_size
=
field_defn
.
connection_max_page_size
||
ctx
.
schema
.
default_max_page_size
limit_value
=
[
args
[
:first
],
args
[
:last
],
page_size
].
compact
.
min
multiplier
=
self
.
resolver
&
.
try
(
:complexity_multiplier
,
args
).
to_f
multiplier
=
resolver
&
.
try
(
:complexity_multiplier
,
args
).
to_f
limit_value
*
multiplier
end
end
...
...
spec/graphql/gitlab_schema_spec.rb
View file @
a379ab20
...
...
@@ -47,7 +47,7 @@ RSpec.describe GitlabSchema do
end
describe
'.execute'
do
context
'
for
different types of users'
do
context
'
with
different types of users'
do
context
'when no context'
do
it
'returns DEFAULT_MAX_COMPLEXITY'
do
expect
(
GraphQL
::
Schema
)
...
...
@@ -78,13 +78,15 @@ RSpec.describe GitlabSchema do
context
'when a logged in user'
do
it
'returns AUTHENTICATED_COMPLEXITY'
do
expect
(
GraphQL
::
Schema
).
to
receive
(
:execute
).
with
(
'query'
,
hash_including
(
max_complexity:
GitlabSchema
::
AUTHENTICATED_COMPLEXITY
))
expect
(
GraphQL
::
Schema
).
to
receive
(
:execute
)
.
with
(
'query'
,
hash_including
(
max_complexity:
GitlabSchema
::
AUTHENTICATED_COMPLEXITY
))
described_class
.
execute
(
'query'
,
context:
{
current_user:
user
})
end
it
'returns AUTHENTICATED_MAX_DEPTH'
do
expect
(
GraphQL
::
Schema
).
to
receive
(
:execute
).
with
(
'query'
,
hash_including
(
max_depth:
GitlabSchema
::
AUTHENTICATED_MAX_DEPTH
))
expect
(
GraphQL
::
Schema
).
to
receive
(
:execute
)
.
with
(
'query'
,
hash_including
(
max_depth:
GitlabSchema
::
AUTHENTICATED_MAX_DEPTH
))
described_class
.
execute
(
'query'
,
context:
{
current_user:
user
})
end
...
...
@@ -94,7 +96,8 @@ RSpec.describe GitlabSchema do
it
'returns ADMIN_COMPLEXITY'
do
user
=
build
:user
,
:admin
expect
(
GraphQL
::
Schema
).
to
receive
(
:execute
).
with
(
'query'
,
hash_including
(
max_complexity:
GitlabSchema
::
ADMIN_COMPLEXITY
))
expect
(
GraphQL
::
Schema
).
to
receive
(
:execute
)
.
with
(
'query'
,
hash_including
(
max_complexity:
GitlabSchema
::
ADMIN_COMPLEXITY
))
described_class
.
execute
(
'query'
,
context:
{
current_user:
user
})
end
...
...
@@ -130,7 +133,7 @@ RSpec.describe GitlabSchema do
end
describe
'.object_from_id'
do
context
'
for
subclasses of `ApplicationRecord`'
do
context
'
with
subclasses of `ApplicationRecord`'
do
let_it_be
(
:user
)
{
create
(
:user
)
}
it
'returns the correct record'
do
...
...
@@ -162,7 +165,7 @@ RSpec.describe GitlabSchema do
end
end
context
'
for
classes that are not ActiveRecord subclasses and have implemented .lazy_find'
do
context
'
with
classes that are not ActiveRecord subclasses and have implemented .lazy_find'
do
it
'returns the correct record'
do
note
=
create
(
:discussion_note_on_merge_request
)
...
...
@@ -182,7 +185,7 @@ RSpec.describe GitlabSchema do
end
end
context
'
for
other classes'
do
context
'
with
other classes'
do
# We cannot use an anonymous class here as `GlobalID` expects `.name` not
# to return `nil`
before
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