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
d2b362b9
Commit
d2b362b9
authored
Aug 25, 2020
by
Paul Slaughter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix axios automatically parsing snippet content
This caused JSON values to not be loaded properly
parent
92bb931d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
2 deletions
+25
-2
app/assets/javascripts/snippets/components/snippet_blob_edit.vue
...ets/javascripts/snippets/components/snippet_blob_edit.vue
+4
-1
changelogs/unreleased/241199-fix-snippet-loading-json-content.yml
...gs/unreleased/241199-fix-snippet-loading-json-content.yml
+5
-0
spec/frontend/snippets/components/snippet_blob_edit_spec.js
spec/frontend/snippets/components/snippet_blob_edit_spec.js
+16
-1
No files found.
app/assets/javascripts/snippets/components/snippet_blob_edit.vue
View file @
d2b362b9
...
...
@@ -53,7 +53,10 @@ export default {
const
url
=
joinPaths
(
baseUrl
,
this
.
blob
.
rawPath
);
axios
.
get
(
url
)
.
get
(
url
,
{
// This prevents axios from automatically JSON.parse response
transformResponse
:
[
f
=>
f
],
})
.
then
(
res
=>
{
this
.
notifyAboutUpdates
({
content
:
res
.
data
});
})
...
...
changelogs/unreleased/241199-fix-snippet-loading-json-content.yml
0 → 100644
View file @
d2b362b9
---
title
:
Fix snippets edit not loading JSON values
merge_request
:
40417
author
:
type
:
fixed
spec/frontend/snippets/components/snippet_blob_edit_spec.js
View file @
d2b362b9
...
...
@@ -17,6 +17,7 @@ const TEST_PATH = 'foo/bar/test.md';
const
TEST_RAW_PATH
=
'
/gitlab/raw/path/to/blob/7
'
;
const
TEST_FULL_PATH
=
joinPaths
(
TEST_HOST
,
TEST_RAW_PATH
);
const
TEST_CONTENT
=
'
Lorem ipsum dolar sit amet,
\n
consectetur adipiscing elit.
'
;
const
TEST_JSON_CONTENT
=
'
{"abc":"lorem ipsum"}
'
;
const
TEST_BLOB
=
{
id
:
TEST_ID
,
...
...
@@ -66,7 +67,7 @@ describe('Snippet Blob Edit component', () => {
});
describe
(
'
with not loaded blob
'
,
()
=>
{
beforeEach
(
async
()
=>
{
beforeEach
(()
=>
{
createComponent
();
});
...
...
@@ -100,6 +101,20 @@ describe('Snippet Blob Edit component', () => {
});
});
describe
(
'
with unloaded blob and JSON content
'
,
()
=>
{
beforeEach
(()
=>
{
axiosMock
.
onGet
(
TEST_FULL_PATH
).
reply
(
200
,
TEST_JSON_CONTENT
);
createComponent
();
});
// This checks against this issue https://gitlab.com/gitlab-org/gitlab/-/issues/241199
it
(
'
emits raw content
'
,
async
()
=>
{
await
waitForPromises
();
expect
(
getLastUpdatedArgs
()).
toEqual
({
content
:
TEST_JSON_CONTENT
});
});
});
describe
(
'
with error
'
,
()
=>
{
beforeEach
(()
=>
{
axiosMock
.
reset
();
...
...
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