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
2cab4268
Commit
2cab4268
authored
Nov 17, 2021
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not omit nil results using graphql_dig_at
parent
5e02ef43
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
4 deletions
+22
-4
spec/graphql/types/base_edge_spec.rb
spec/graphql/types/base_edge_spec.rb
+1
-1
spec/requests/api/graphql/packages/package_spec.rb
spec/requests/api/graphql/packages/package_spec.rb
+1
-1
spec/support/helpers/graphql_helpers.rb
spec/support/helpers/graphql_helpers.rb
+4
-1
spec/support/shared_examples/requests/api/graphql/packages/group_and_project_packages_list_shared_examples.rb
...ckages/group_and_project_packages_list_shared_examples.rb
+1
-1
spec/support_specs/helpers/graphql_helpers_spec.rb
spec/support_specs/helpers/graphql_helpers_spec.rb
+15
-0
No files found.
spec/graphql/types/base_edge_spec.rb
View file @
2cab4268
...
@@ -71,6 +71,6 @@ RSpec.describe Types::BaseEdge do
...
@@ -71,6 +71,6 @@ RSpec.describe Types::BaseEdge do
.
to
contain_exactly
(
member_project
.
name
,
maintainer_project
.
name
,
public_project
.
name
)
.
to
contain_exactly
(
member_project
.
name
,
maintainer_project
.
name
,
public_project
.
name
)
expect
(
graphql_dig_at
(
result
,
'data'
,
'projects'
,
'edges'
,
'proofOfAdminRights'
))
expect
(
graphql_dig_at
(
result
,
'data'
,
'projects'
,
'edges'
,
'proofOfAdminRights'
))
.
to
contain_exactly
(
'ok'
)
.
to
contain_exactly
(
nil
,
'ok'
,
nil
)
end
end
end
end
spec/requests/api/graphql/packages/package_spec.rb
View file @
2cab4268
...
@@ -68,7 +68,7 @@ RSpec.describe 'package details' do
...
@@ -68,7 +68,7 @@ RSpec.describe 'package details' do
subject
subject
expect
(
graphql_data_at
(
:package
,
:versions
,
:nodes
,
:version
)).
to
be_present
expect
(
graphql_data_at
(
:package
,
:versions
,
:nodes
,
:version
)).
to
be_present
expect
(
graphql_data_at
(
:package
,
:versions
,
:nodes
,
:versions
,
:nodes
)).
to
be_empty
expect
(
graphql_data_at
(
:package
,
:versions
,
:nodes
,
:versions
,
:nodes
)).
to
eq
[
nil
,
nil
]
end
end
end
end
end
end
...
...
spec/support/helpers/graphql_helpers.rb
View file @
2cab4268
...
@@ -515,7 +515,10 @@ module GraphqlHelpers
...
@@ -515,7 +515,10 @@ module GraphqlHelpers
# ['project', 'boards', 'edges', 0, 'node', 'lists']
# ['project', 'boards', 'edges', 0, 'node', 'lists']
keys
.
reduce
(
data
)
do
|
memo
,
key
|
keys
.
reduce
(
data
)
do
|
memo
,
key
|
if
memo
.
is_a?
(
Array
)
if
memo
.
is_a?
(
Array
)
key
.
is_a?
(
Integer
)
?
memo
[
key
]
:
memo
.
flat_map
{
|
e
|
Array
.
wrap
(
e
[
key
])
}
key
.
is_a?
(
Integer
)
?
memo
[
key
]
:
memo
.
compact
.
flat_map
do
|
e
|
x
=
e
[
key
]
x
.
nil?
?
[
x
]
:
Array
.
wrap
(
x
)
end
else
else
memo
&
.
dig
(
key
)
memo
&
.
dig
(
key
)
end
end
...
...
spec/support/shared_examples/requests/api/graphql/packages/group_and_project_packages_list_shared_examples.rb
View file @
2cab4268
...
@@ -55,7 +55,7 @@ RSpec.shared_examples 'group and project packages query' do
...
@@ -55,7 +55,7 @@ RSpec.shared_examples 'group and project packages query' do
end
end
it
'deals with metadata'
do
it
'deals with metadata'
do
expect
(
target_shas
).
to
contain_exactly
(
composer_metadatum
.
target_sha
)
expect
(
target_shas
.
compact
).
to
contain_exactly
(
composer_metadatum
.
target_sha
)
end
end
it
'returns the count of the packages'
do
it
'returns the count of the packages'
do
...
...
spec/support_specs/helpers/graphql_helpers_spec.rb
View file @
2cab4268
...
@@ -43,6 +43,21 @@ RSpec.describe GraphqlHelpers do
...
@@ -43,6 +43,21 @@ RSpec.describe GraphqlHelpers do
expect
(
graphql_dig_at
(
data
,
:foo
,
:nodes
,
:bar
,
:nodes
,
:id
)).
to
eq
([
1
,
2
,
3
,
4
])
expect
(
graphql_dig_at
(
data
,
:foo
,
:nodes
,
:bar
,
:nodes
,
:id
)).
to
eq
([
1
,
2
,
3
,
4
])
end
end
it
'does not omit nils at the leaves'
do
data
=
{
'foo'
=>
{
'nodes'
=>
[
{
'bar'
=>
{
'nodes'
=>
[{
'id'
=>
nil
},
{
'id'
=>
2
}]
}
},
{
'bar'
=>
{
'nodes'
=>
[{
'id'
=>
3
},
{
'id'
=>
nil
}]
}
},
{
'bar'
=>
nil
}
]
},
'irrelevant'
=>
'the field is a red-herring'
}
expect
(
graphql_dig_at
(
data
,
:foo
,
:nodes
,
:bar
,
:nodes
,
:id
)).
to
eq
([
nil
,
2
,
3
,
nil
])
end
end
end
describe
'var'
do
describe
'var'
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