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
31e843e4
Commit
31e843e4
authored
Feb 12, 2020
by
Francisco Javier López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug rendering BlobType markdown data
parent
66acda99
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
57 additions
and
40 deletions
+57
-40
app/graphql/types/snippets/blob_type.rb
app/graphql/types/snippets/blob_type.rb
+2
-2
app/presenters/snippet_blob_presenter.rb
app/presenters/snippet_blob_presenter.rb
+12
-4
changelogs/unreleased/fj-fix-bug-rendering-snippet-blob-markdown.yml
...unreleased/fj-fix-bug-rendering-snippet-blob-markdown.yml
+5
-0
doc/api/graphql/reference/gitlab_schema.graphql
doc/api/graphql/reference/gitlab_schema.graphql
+6
-6
doc/api/graphql/reference/gitlab_schema.json
doc/api/graphql/reference/gitlab_schema.json
+15
-15
doc/api/graphql/reference/index.md
doc/api/graphql/reference/index.md
+2
-2
spec/graphql/types/snippets/blob_type_spec.rb
spec/graphql/types/snippets/blob_type_spec.rb
+1
-1
spec/presenters/snippet_blob_presenter_spec.rb
spec/presenters/snippet_blob_presenter_spec.rb
+6
-6
spec/requests/api/graphql/mutations/snippets/create_spec.rb
spec/requests/api/graphql/mutations/snippets/create_spec.rb
+4
-2
spec/requests/api/graphql/mutations/snippets/update_spec.rb
spec/requests/api/graphql/mutations/snippets/update_spec.rb
+4
-2
No files found.
app/graphql/types/snippets/blob_type.rb
View file @
31e843e4
...
@@ -8,11 +8,11 @@ module Types
...
@@ -8,11 +8,11 @@ module Types
description
'Represents the snippet blob'
description
'Represents the snippet blob'
present_using
SnippetBlobPresenter
present_using
SnippetBlobPresenter
field
:
highlighted
_data
,
GraphQL
::
STRING_TYPE
,
field
:
rich
_data
,
GraphQL
::
STRING_TYPE
,
description:
'Blob highlighted data'
,
description:
'Blob highlighted data'
,
null:
true
null:
true
field
:plain_
highlighted_
data
,
GraphQL
::
STRING_TYPE
,
field
:plain_data
,
GraphQL
::
STRING_TYPE
,
description:
'Blob plain highlighted data'
,
description:
'Blob plain highlighted data'
,
null:
true
null:
true
...
...
app/presenters/snippet_blob_presenter.rb
View file @
31e843e4
# frozen_string_literal: true
# frozen_string_literal: true
class
SnippetBlobPresenter
<
BlobPresenter
class
SnippetBlobPresenter
<
BlobPresenter
def
highlighted
_data
def
rich
_data
return
if
blob
.
binary?
return
if
blob
.
binary?
if
markup?
blob
.
rendered_markup
else
highlight
(
plain:
false
)
highlight
(
plain:
false
)
end
end
end
def
plain_
highlighted_
data
def
plain_data
return
if
blob
.
binary?
return
if
blob
.
binary?
highlight
(
plain:
true
)
highlight
(
plain:
!
markup?
)
end
end
def
raw_path
def
raw_path
...
@@ -23,6 +27,10 @@ class SnippetBlobPresenter < BlobPresenter
...
@@ -23,6 +27,10 @@ class SnippetBlobPresenter < BlobPresenter
private
private
def
markup?
blob
.
rich_viewer
&
.
partial_name
==
'markup'
end
def
snippet
def
snippet
blob
.
snippet
blob
.
snippet
end
end
...
...
changelogs/unreleased/fj-fix-bug-rendering-snippet-blob-markdown.yml
0 → 100644
View file @
31e843e4
---
title
:
Fix bug rendering BlobType markdown data
merge_request
:
24960
author
:
type
:
fixed
doc/api/graphql/reference/gitlab_schema.graphql
View file @
31e843e4
...
@@ -6757,11 +6757,6 @@ type SnippetBlob {
...
@@ -6757,11 +6757,6 @@ type SnippetBlob {
"""
"""
binary
:
Boolean
!
binary
:
Boolean
!
"""
Blob
highlighted
data
"""
highlightedData
:
String
"""
"""
Blob
mode
Blob
mode
"""
"""
...
@@ -6780,13 +6775,18 @@ type SnippetBlob {
...
@@ -6780,13 +6775,18 @@ type SnippetBlob {
"""
"""
Blob
plain
highlighted
data
Blob
plain
highlighted
data
"""
"""
plain
Highlighted
Data
:
String
plainData
:
String
"""
"""
Blob
raw
content
endpoint
path
Blob
raw
content
endpoint
path
"""
"""
rawPath
:
String
!
rawPath
:
String
!
"""
Blob
highlighted
data
"""
richData
:
String
"""
"""
Blob
content
rich
viewer
Blob
content
rich
viewer
"""
"""
...
...
doc/api/graphql/reference/gitlab_schema.json
View file @
31e843e4
...
@@ -7556,20 +7556,6 @@
...
@@ -7556,20 +7556,6 @@
"isDeprecated"
:
false
,
"isDeprecated"
:
false
,
"deprecationReason"
:
null
"deprecationReason"
:
null
},
},
{
"name"
:
"highlightedData"
,
"description"
:
"Blob highlighted data"
,
"args"
:
[
],
"type"
:
{
"kind"
:
"SCALAR"
,
"name"
:
"String"
,
"ofType"
:
null
},
"isDeprecated"
:
false
,
"deprecationReason"
:
null
},
{
{
"name"
:
"mode"
,
"name"
:
"mode"
,
"description"
:
"Blob mode"
,
"description"
:
"Blob mode"
,
...
@@ -7613,7 +7599,7 @@
...
@@ -7613,7 +7599,7 @@
"deprecationReason"
:
null
"deprecationReason"
:
null
},
},
{
{
"name"
:
"plain
Highlighted
Data"
,
"name"
:
"plainData"
,
"description"
:
"Blob plain highlighted data"
,
"description"
:
"Blob plain highlighted data"
,
"args"
:
[
"args"
:
[
...
@@ -7644,6 +7630,20 @@
...
@@ -7644,6 +7630,20 @@
"isDeprecated"
:
false
,
"isDeprecated"
:
false
,
"deprecationReason"
:
null
"deprecationReason"
:
null
},
},
{
"name"
:
"richData"
,
"description"
:
"Blob highlighted data"
,
"args"
:
[
],
"type"
:
{
"kind"
:
"SCALAR"
,
"name"
:
"String"
,
"ofType"
:
null
},
"isDeprecated"
:
false
,
"deprecationReason"
:
null
},
{
{
"name"
:
"richViewer"
,
"name"
:
"richViewer"
,
"description"
:
"Blob content rich viewer"
,
"description"
:
"Blob content rich viewer"
,
...
...
doc/api/graphql/reference/index.md
View file @
31e843e4
...
@@ -1067,12 +1067,12 @@ Represents the snippet blob
...
@@ -1067,12 +1067,12 @@ Represents the snippet blob
| Name | Type | Description |
| Name | Type | Description |
| --- | ---- | ---------- |
| --- | ---- | ---------- |
|
`binary`
| Boolean! | Shows whether the blob is binary |
|
`binary`
| Boolean! | Shows whether the blob is binary |
|
`highlightedData`
| String | Blob highlighted data |
|
`mode`
| String | Blob mode |
|
`mode`
| String | Blob mode |
|
`name`
| String | Blob name |
|
`name`
| String | Blob name |
|
`path`
| String | Blob path |
|
`path`
| String | Blob path |
|
`plain
Highlighted
Data`
| String | Blob plain highlighted data |
|
`plainData`
| String | Blob plain highlighted data |
|
`rawPath`
| String! | Blob raw content endpoint path |
|
`rawPath`
| String! | Blob raw content endpoint path |
|
`richData`
| String | Blob highlighted data |
|
`richViewer`
| SnippetBlobViewer | Blob content rich viewer |
|
`richViewer`
| SnippetBlobViewer | Blob content rich viewer |
|
`simpleViewer`
| SnippetBlobViewer! | Blob content simple viewer |
|
`simpleViewer`
| SnippetBlobViewer! | Blob content simple viewer |
|
`size`
| Int! | Blob size |
|
`size`
| Int! | Blob size |
...
...
spec/graphql/types/snippets/blob_type_spec.rb
View file @
31e843e4
...
@@ -4,7 +4,7 @@ require 'spec_helper'
...
@@ -4,7 +4,7 @@ require 'spec_helper'
describe
GitlabSchema
.
types
[
'SnippetBlob'
]
do
describe
GitlabSchema
.
types
[
'SnippetBlob'
]
do
it
'has the correct fields'
do
it
'has the correct fields'
do
expected_fields
=
[
:
highlighted_data
,
:plain_highlighted
_data
,
expected_fields
=
[
:
rich_data
,
:plain
_data
,
:raw_path
,
:size
,
:binary
,
:name
,
:path
,
:raw_path
,
:size
,
:binary
,
:name
,
:path
,
:simple_viewer
,
:rich_viewer
,
:mode
]
:simple_viewer
,
:rich_viewer
,
:mode
]
...
...
spec/presenters/snippet_blob_presenter_spec.rb
View file @
31e843e4
...
@@ -3,10 +3,10 @@
...
@@ -3,10 +3,10 @@
require
'spec_helper'
require
'spec_helper'
describe
SnippetBlobPresenter
do
describe
SnippetBlobPresenter
do
describe
'#
highlighted
_data'
do
describe
'#
rich
_data'
do
let
(
:snippet
)
{
build
(
:personal_snippet
)
}
let
(
:snippet
)
{
build
(
:personal_snippet
)
}
subject
{
described_class
.
new
(
snippet
.
blob
).
highlighted
_data
}
subject
{
described_class
.
new
(
snippet
.
blob
).
rich
_data
}
it
'returns nil when the snippet blob is binary'
do
it
'returns nil when the snippet blob is binary'
do
allow
(
snippet
.
blob
).
to
receive
(
:binary?
).
and_return
(
true
)
allow
(
snippet
.
blob
).
to
receive
(
:binary?
).
and_return
(
true
)
...
@@ -18,7 +18,7 @@ describe SnippetBlobPresenter do
...
@@ -18,7 +18,7 @@ describe SnippetBlobPresenter do
snippet
.
file_name
=
'test.md'
snippet
.
file_name
=
'test.md'
snippet
.
content
=
'*foo*'
snippet
.
content
=
'*foo*'
expect
(
subject
).
to
eq
'<
span id="LC1" class="line" lang="markdown"><span class="ge">*foo*</span></span
>'
expect
(
subject
).
to
eq
'<
p data-sourcepos="1:1-1:5" dir="auto"><em>foo</em></p
>'
end
end
it
'returns syntax highlighted content'
do
it
'returns syntax highlighted content'
do
...
@@ -37,10 +37,10 @@ describe SnippetBlobPresenter do
...
@@ -37,10 +37,10 @@ describe SnippetBlobPresenter do
end
end
end
end
describe
'#plain_
highlighted_
data'
do
describe
'#plain_data'
do
let
(
:snippet
)
{
build
(
:personal_snippet
)
}
let
(
:snippet
)
{
build
(
:personal_snippet
)
}
subject
{
described_class
.
new
(
snippet
.
blob
).
plain_
highlighted_
data
}
subject
{
described_class
.
new
(
snippet
.
blob
).
plain_data
}
it
'returns nil when the snippet blob is binary'
do
it
'returns nil when the snippet blob is binary'
do
allow
(
snippet
.
blob
).
to
receive
(
:binary?
).
and_return
(
true
)
allow
(
snippet
.
blob
).
to
receive
(
:binary?
).
and_return
(
true
)
...
@@ -52,7 +52,7 @@ describe SnippetBlobPresenter do
...
@@ -52,7 +52,7 @@ describe SnippetBlobPresenter do
snippet
.
file_name
=
'test.md'
snippet
.
file_name
=
'test.md'
snippet
.
content
=
'*foo*'
snippet
.
content
=
'*foo*'
expect
(
subject
).
to
eq
'<span id="LC1" class="line" lang="
">*foo*
</span>'
expect
(
subject
).
to
eq
'<span id="LC1" class="line" lang="
markdown"><span class="ge">*foo*</span>
</span>'
end
end
it
'returns plain syntax content'
do
it
'returns plain syntax content'
do
...
...
spec/requests/api/graphql/mutations/snippets/create_spec.rb
View file @
31e843e4
...
@@ -67,7 +67,8 @@ describe 'Creating a Snippet' do
...
@@ -67,7 +67,8 @@ describe 'Creating a Snippet' do
it
'returns the created Snippet'
do
it
'returns the created Snippet'
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
mutation_response
[
'snippet'
][
'blob'
][
'highlightedData'
]).
to
match
(
content
)
expect
(
mutation_response
[
'snippet'
][
'blob'
][
'richData'
]).
to
match
(
content
)
expect
(
mutation_response
[
'snippet'
][
'blob'
][
'plainData'
]).
to
match
(
content
)
expect
(
mutation_response
[
'snippet'
][
'title'
]).
to
eq
(
title
)
expect
(
mutation_response
[
'snippet'
][
'title'
]).
to
eq
(
title
)
expect
(
mutation_response
[
'snippet'
][
'description'
]).
to
eq
(
description
)
expect
(
mutation_response
[
'snippet'
][
'description'
]).
to
eq
(
description
)
expect
(
mutation_response
[
'snippet'
][
'fileName'
]).
to
eq
(
file_name
)
expect
(
mutation_response
[
'snippet'
][
'fileName'
]).
to
eq
(
file_name
)
...
@@ -92,7 +93,8 @@ describe 'Creating a Snippet' do
...
@@ -92,7 +93,8 @@ describe 'Creating a Snippet' do
it
'returns the created Snippet'
do
it
'returns the created Snippet'
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
mutation_response
[
'snippet'
][
'blob'
][
'highlightedData'
]).
to
match
(
content
)
expect
(
mutation_response
[
'snippet'
][
'blob'
][
'richData'
]).
to
match
(
content
)
expect
(
mutation_response
[
'snippet'
][
'blob'
][
'plainData'
]).
to
match
(
content
)
expect
(
mutation_response
[
'snippet'
][
'title'
]).
to
eq
(
title
)
expect
(
mutation_response
[
'snippet'
][
'title'
]).
to
eq
(
title
)
expect
(
mutation_response
[
'snippet'
][
'description'
]).
to
eq
(
description
)
expect
(
mutation_response
[
'snippet'
][
'description'
]).
to
eq
(
description
)
expect
(
mutation_response
[
'snippet'
][
'fileName'
]).
to
eq
(
file_name
)
expect
(
mutation_response
[
'snippet'
][
'fileName'
]).
to
eq
(
file_name
)
...
...
spec/requests/api/graphql/mutations/snippets/update_spec.rb
View file @
31e843e4
...
@@ -56,7 +56,8 @@ describe 'Updating a Snippet' do
...
@@ -56,7 +56,8 @@ describe 'Updating a Snippet' do
it
'returns the updated Snippet'
do
it
'returns the updated Snippet'
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
mutation_response
[
'snippet'
][
'blob'
][
'highlightedData'
]).
to
match
(
updated_content
)
expect
(
mutation_response
[
'snippet'
][
'blob'
][
'richData'
]).
to
match
(
updated_content
)
expect
(
mutation_response
[
'snippet'
][
'blob'
][
'plainData'
]).
to
match
(
updated_content
)
expect
(
mutation_response
[
'snippet'
][
'title'
]).
to
eq
(
updated_title
)
expect
(
mutation_response
[
'snippet'
][
'title'
]).
to
eq
(
updated_title
)
expect
(
mutation_response
[
'snippet'
][
'description'
]).
to
eq
(
updated_description
)
expect
(
mutation_response
[
'snippet'
][
'description'
]).
to
eq
(
updated_description
)
expect
(
mutation_response
[
'snippet'
][
'fileName'
]).
to
eq
(
updated_file_name
)
expect
(
mutation_response
[
'snippet'
][
'fileName'
]).
to
eq
(
updated_file_name
)
...
@@ -77,7 +78,8 @@ describe 'Updating a Snippet' do
...
@@ -77,7 +78,8 @@ describe 'Updating a Snippet' do
it
'returns the Snippet with its original values'
do
it
'returns the Snippet with its original values'
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
mutation_response
[
'snippet'
][
'blob'
][
'highlightedData'
]).
to
match
(
original_content
)
expect
(
mutation_response
[
'snippet'
][
'blob'
][
'richData'
]).
to
match
(
original_content
)
expect
(
mutation_response
[
'snippet'
][
'blob'
][
'plainData'
]).
to
match
(
original_content
)
expect
(
mutation_response
[
'snippet'
][
'title'
]).
to
eq
(
original_title
)
expect
(
mutation_response
[
'snippet'
][
'title'
]).
to
eq
(
original_title
)
expect
(
mutation_response
[
'snippet'
][
'description'
]).
to
eq
(
original_description
)
expect
(
mutation_response
[
'snippet'
][
'description'
]).
to
eq
(
original_description
)
expect
(
mutation_response
[
'snippet'
][
'fileName'
]).
to
eq
(
original_file_name
)
expect
(
mutation_response
[
'snippet'
][
'fileName'
]).
to
eq
(
original_file_name
)
...
...
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