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
180203a5
Commit
180203a5
authored
May 01, 2020
by
Francisco Javier López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug in Snippet BlobViewer GraphQL definition
parent
0138ae8a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
91 additions
and
2 deletions
+91
-2
app/graphql/types/snippets/blob_type.rb
app/graphql/types/snippets/blob_type.rb
+1
-0
app/graphql/types/snippets/blob_viewer_type.rb
app/graphql/types/snippets/blob_viewer_type.rb
+4
-2
changelogs/unreleased/fj-fix-bug-snippet-blob-viewer-graphql.yml
...ogs/unreleased/fj-fix-bug-snippet-blob-viewer-graphql.yml
+5
-0
spec/graphql/types/snippets/blob_viewer_type_spec.rb
spec/graphql/types/snippets/blob_viewer_type_spec.rb
+81
-0
No files found.
app/graphql/types/snippets/blob_type.rb
View file @
180203a5
...
...
@@ -14,6 +14,7 @@ module Types
field
:plain_data
,
GraphQL
::
STRING_TYPE
,
description:
'Blob plain highlighted data'
,
calls_gitaly:
true
,
null:
true
field
:raw_path
,
GraphQL
::
STRING_TYPE
,
...
...
app/graphql/types/snippets/blob_viewer_type.rb
View file @
180203a5
...
...
@@ -17,12 +17,14 @@ module Types
field
:collapsed
,
GraphQL
::
BOOLEAN_TYPE
,
description:
'Shows whether the blob should be displayed collapsed'
,
method: :collapsed?
,
null:
false
null:
false
,
resolve:
->
(
viewer
,
_args
,
_ctx
)
{
!!
viewer
&
.
collapsed?
}
field
:too_large
,
GraphQL
::
BOOLEAN_TYPE
,
description:
'Shows whether the blob too large to be displayed'
,
method: :too_large?
,
null:
false
null:
false
,
resolve:
->
(
viewer
,
_args
,
_ctx
)
{
!!
viewer
&
.
too_large?
}
field
:render_error
,
GraphQL
::
STRING_TYPE
,
description:
'Error rendering the blob content'
,
...
...
changelogs/unreleased/fj-fix-bug-snippet-blob-viewer-graphql.yml
0 → 100644
View file @
180203a5
---
title
:
Fix bug in Snippet BlobViewer GraphQL definition
merge_request
:
30927
author
:
type
:
fixed
spec/graphql/types/snippets/blob_viewer_type_spec.rb
View file @
180203a5
...
...
@@ -3,10 +3,91 @@
require
'spec_helper'
describe
GitlabSchema
.
types
[
'SnippetBlobViewer'
]
do
let_it_be
(
:snippet
)
{
create
(
:personal_snippet
,
:repository
)
}
let_it_be
(
:blob
)
{
snippet
.
repository
.
blob_at
(
'HEAD'
,
'files/images/6049019_460s.jpg'
)
}
it
'has the correct fields'
do
expected_fields
=
[
:type
,
:load_async
,
:too_large
,
:collapsed
,
:render_error
,
:file_type
,
:loading_partial_name
]
expect
(
described_class
).
to
have_graphql_fields
(
*
expected_fields
)
end
it
{
expect
(
described_class
.
fields
[
'type'
].
type
).
to
be_non_null
}
it
{
expect
(
described_class
.
fields
[
'loadAsync'
].
type
).
to
be_non_null
}
it
{
expect
(
described_class
.
fields
[
'collapsed'
].
type
).
to
be_non_null
}
it
{
expect
(
described_class
.
fields
[
'tooLarge'
].
type
).
to
be_non_null
}
it
{
expect
(
described_class
.
fields
[
'renderError'
].
type
).
not_to
be_non_null
}
it
{
expect
(
described_class
.
fields
[
'fileType'
].
type
).
to
be_non_null
}
it
{
expect
(
described_class
.
fields
[
'loadingPartialName'
].
type
).
to
be_non_null
}
shared_examples
'nil field converted to false'
do
subject
{
GitlabSchema
.
execute
(
query
,
context:
{
current_user:
snippet
.
author
}).
as_json
}
before
do
allow_next_instance_of
(
SnippetPresenter
)
do
|
instance
|
allow
(
instance
).
to
receive
(
:blob
).
and_return
(
blob
)
end
end
it
'returns false'
do
snippet_blob
=
subject
.
dig
(
'data'
,
'snippets'
,
'edges'
)[
0
].
dig
(
'node'
,
'blob'
)
expect
(
snippet_blob
[
'path'
]).
to
eq
blob
.
path
expect
(
blob_attribute
).
to
be_nil
expect
(
snippet_blob
[
'simpleViewer'
][
attribute
]).
to
eq
false
end
end
describe
'collapsed'
do
it_behaves_like
'nil field converted to false'
do
let
(
:query
)
do
%(
query {
snippets(ids:"#{snippet.to_global_id}"){
edges {
node {
blob {
path
simpleViewer {
collapsed
}
}
}
}
}
}
)
end
let
(
:attribute
)
{
'collapsed'
}
let
(
:blob_attribute
)
{
blob
.
simple_viewer
.
collapsed?
}
end
end
describe
'tooLarge'
do
it_behaves_like
'nil field converted to false'
do
let
(
:query
)
do
%(
query {
snippets(ids:"#{snippet.to_global_id}"){
edges {
node {
blob {
path
simpleViewer {
tooLarge
}
}
}
}
}
}
)
end
let
(
:attribute
)
{
'tooLarge'
}
let
(
:blob_attribute
)
{
blob
.
simple_viewer
.
too_large?
}
end
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