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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
beeeede2
Commit
beeeede2
authored
Apr 04, 2019
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a KeyError in GitlabSchema
parent
465f82e3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
app/graphql/gitlab_schema.rb
app/graphql/gitlab_schema.rb
+1
-1
spec/graphql/gitlab_schema_spec.rb
spec/graphql/gitlab_schema_spec.rb
+12
-2
No files found.
app/graphql/gitlab_schema.rb
View file @
beeeede2
...
@@ -31,7 +31,7 @@ class GitlabSchema < GraphQL::Schema
...
@@ -31,7 +31,7 @@ class GitlabSchema < GraphQL::Schema
end
end
def
self
.
max_query_complexity
(
ctx
)
def
self
.
max_query_complexity
(
ctx
)
current_user
=
ctx
&
.
fetch
(
:current_user
)
current_user
=
ctx
&
.
fetch
(
:current_user
,
nil
)
if
current_user
&
.
admin
if
current_user
&
.
admin
ADMIN_COMPLEXITY
ADMIN_COMPLEXITY
...
...
spec/graphql/gitlab_schema_spec.rb
View file @
beeeede2
...
@@ -34,12 +34,22 @@ describe GitlabSchema do
...
@@ -34,12 +34,22 @@ describe GitlabSchema do
end
end
context
'for different types of users'
do
context
'for different types of users'
do
it
'returns DEFAULT_MAX_COMPLEXITY for no user'
do
it
'returns DEFAULT_MAX_COMPLEXITY for no context'
do
expect
(
GraphQL
::
Schema
).
to
receive
(
:execute
).
with
(
'query'
,
hash_including
(
max_complexity:
GitlabSchema
::
DEFAULT_MAX_COMPLEXITY
))
expect
(
GraphQL
::
Schema
)
.
to
receive
(
:execute
)
.
with
(
'query'
,
hash_including
(
max_complexity:
GitlabSchema
::
DEFAULT_MAX_COMPLEXITY
))
described_class
.
execute
(
'query'
)
described_class
.
execute
(
'query'
)
end
end
it
'returns DEFAULT_MAX_COMPLEXITY for no user'
do
expect
(
GraphQL
::
Schema
)
.
to
receive
(
:execute
)
.
with
(
'query'
,
hash_including
(
max_complexity:
GitlabSchema
::
DEFAULT_MAX_COMPLEXITY
))
described_class
.
execute
(
'query'
,
context:
{})
end
it
'returns AUTHENTICATED_COMPLEXITY for a logged in user'
do
it
'returns AUTHENTICATED_COMPLEXITY for a logged in user'
do
user
=
build
:user
user
=
build
:user
...
...
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