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
f4fe15fe
Commit
f4fe15fe
authored
Dec 02, 2020
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return empty results rather than raising errors
parent
58931f4a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
8 deletions
+18
-8
spec/graphql/resolvers/snippets/blobs_resolver_spec.rb
spec/graphql/resolvers/snippets/blobs_resolver_spec.rb
+18
-8
No files found.
spec/graphql/resolvers/snippets/blobs_resolver_spec.rb
View file @
f4fe15fe
...
...
@@ -16,16 +16,18 @@ RSpec.describe Resolvers::Snippets::BlobsResolver do
context
'when user is not authorized'
do
let
(
:other_user
)
{
create
(
:user
)
}
it
'raises an error'
do
expect
do
resolve_blobs
(
snippet
,
user:
other_user
)
end
.
to
raise_error
(
Gitlab
::
Graphql
::
Errors
::
ResourceNotAvailable
)
it
'redacts the field'
do
expect
(
resolve_blobs
(
snippet
,
user:
other_user
)).
to
be_nil
end
end
context
'when using no filter'
do
it
'returns all snippet blobs'
do
expect
(
resolve_blobs
(
snippet
).
map
(
&
:path
)).
to
contain_exactly
(
*
snippet
.
list_files
)
result
=
resolve_blobs
(
snippet
,
args:
{})
expect
(
result
).
to
match_array
(
snippet
.
list_files
.
map
do
|
file
|
have_attributes
(
path:
file
)
end
)
end
end
...
...
@@ -34,7 +36,13 @@ RSpec.describe Resolvers::Snippets::BlobsResolver do
it
'returns an array of files'
do
path
=
'CHANGELOG'
expect
(
resolve_blobs
(
snippet
,
args:
{
paths:
path
}).
first
.
path
).
to
eq
(
path
)
expect
(
resolve_blobs
(
snippet
,
paths:
[
path
])).
to
contain_exactly
(
have_attributes
(
path:
path
))
end
end
context
'the argument does not match anything'
do
it
'returns an empty result'
do
expect
(
resolve_blobs
(
snippet
,
paths:
[
'does not exist'
])).
to
be_empty
end
end
...
...
@@ -42,13 +50,15 @@ RSpec.describe Resolvers::Snippets::BlobsResolver do
it
'returns an array of files'
do
paths
=
[
'CHANGELOG'
,
'README.md'
]
expect
(
resolve_blobs
(
snippet
,
args:
{
paths:
paths
}).
map
(
&
:path
)).
to
contain_exactly
(
*
paths
)
expect
(
resolve_blobs
(
snippet
,
paths:
paths
)).
to
match_array
(
paths
.
map
do
|
file
|
have_attributes
(
path:
file
)
end
)
end
end
end
end
def
resolve_blobs
(
snippet
,
user:
current_user
,
args:
{
})
def
resolve_blobs
(
snippet
,
user:
current_user
,
paths:
[],
args:
{
paths:
paths
})
resolve
(
described_class
,
args:
args
,
ctx:
{
current_user:
user
},
obj:
snippet
)
end
end
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