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
5c21771e
Commit
5c21771e
authored
Sep 24, 2020
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix handling of variables in `post_graphql`
parent
8a5d5b40
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
8 deletions
+30
-8
spec/requests/api/graphql/project/issues_spec.rb
spec/requests/api/graphql/project/issues_spec.rb
+28
-7
spec/support/helpers/graphql_helpers.rb
spec/support/helpers/graphql_helpers.rb
+2
-1
No files found.
spec/requests/api/graphql/project/issues_spec.rb
View file @
5c21771e
...
...
@@ -53,16 +53,37 @@ RSpec.describe 'getting an issue list for a project' do
context
'when limiting the number of results'
do
let
(
:query
)
do
graphql_query_for
(
'project'
,
{
'fullPath'
=>
project
.
full_path
},
"issues(first: 1) {
#{
fields
}
}"
)
<<~
GQL
query($path: ID!, $n: Int) {
project(fullPath: $path) {
issues(first: $n) {
#{
fields
}
}
}
}
GQL
end
let
(
:issue_limit
)
{
1
}
let
(
:variables
)
do
{
path:
project
.
full_path
,
n:
issue_limit
}
end
it_behaves_like
'a working graphql query'
do
before
do
post_graphql
(
query
,
current_user:
current_user
)
post_graphql
(
query
,
current_user:
current_user
,
variables:
variables
)
end
it
'only returns N issues'
do
expect
(
issues_data
.
size
).
to
eq
(
issue_limit
)
end
end
context
'no limit is provided'
do
let
(
:issue_limit
)
{
nil
}
it
'returns all issues'
do
post_graphql
(
query
,
current_user:
current_user
,
variables:
variables
)
expect
(
issues_data
.
size
).
to
be
>
1
end
end
...
...
@@ -71,7 +92,7 @@ RSpec.describe 'getting an issue list for a project' do
# Newest first, we only want to see the newest checked
expect
(
Ability
).
not_to
receive
(
:allowed?
).
with
(
current_user
,
:read_issue
,
issues
.
first
)
post_graphql
(
query
,
current_user:
current_user
)
post_graphql
(
query
,
current_user:
current_user
,
variables:
variables
)
end
end
...
...
spec/support/helpers/graphql_helpers.rb
View file @
5c21771e
...
...
@@ -234,7 +234,8 @@ module GraphqlHelpers
end
def
post_graphql
(
query
,
current_user:
nil
,
variables:
nil
,
headers:
{})
post
api
(
'/'
,
current_user
,
version:
'graphql'
),
params:
{
query:
query
,
variables:
variables
},
headers:
headers
params
=
{
query:
query
,
variables:
variables
&
.
to_json
}
post
api
(
'/'
,
current_user
,
version:
'graphql'
),
params:
params
,
headers:
headers
end
def
post_graphql_mutation
(
mutation
,
current_user:
nil
)
...
...
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