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
ee32e06f
Commit
ee32e06f
authored
Apr 30, 2019
by
Paul Slaughter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix IDE get file data with '/' as relative root
https://gitlab.com/gitlab-org/gitlab-ce/issues/60932
parent
2432a540
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
7 deletions
+24
-7
app/assets/javascripts/ide/stores/actions/file.js
app/assets/javascripts/ide/stores/actions/file.js
+4
-3
changelogs/unreleased/fix-ide-relative-url-bug.yml
changelogs/unreleased/fix-ide-relative-url-bug.yml
+5
-0
spec/javascripts/ide/stores/actions/file_spec.js
spec/javascripts/ide/stores/actions/file_spec.js
+15
-4
No files found.
app/assets/javascripts/ide/stores/actions/file.js
View file @
ee32e06f
import
{
__
}
from
'
../../../locale
'
;
import
{
joinPaths
}
from
'
~/lib/utils/url_utility
'
;
import
{
normalizeHeaders
}
from
'
../../../lib/utils/common_utils
'
;
import
{
normalizeHeaders
}
from
'
~/lib/utils/common_utils
'
;
import
{
__
}
from
'
~/locale
'
;
import
eventHub
from
'
../../eventhub
'
;
import
eventHub
from
'
../../eventhub
'
;
import
service
from
'
../../services
'
;
import
service
from
'
../../services
'
;
import
*
as
types
from
'
../mutation_types
'
;
import
*
as
types
from
'
../mutation_types
'
;
...
@@ -69,7 +70,7 @@ export const getFileData = (
...
@@ -69,7 +70,7 @@ export const getFileData = (
const
url
=
file
.
prevPath
?
file
.
url
.
replace
(
file
.
path
,
file
.
prevPath
)
:
file
.
url
;
const
url
=
file
.
prevPath
?
file
.
url
.
replace
(
file
.
path
,
file
.
prevPath
)
:
file
.
url
;
return
service
return
service
.
getFileData
(
`
${
gon
.
relative_url_root
?
gon
.
relative_url_root
:
''
}${
url
.
replace
(
'
/-/
'
,
'
/
'
)}
`
)
.
getFileData
(
joinPaths
(
gon
.
relative_url_root
||
''
,
url
.
replace
(
'
/-/
'
,
'
/
'
))
)
.
then
(({
data
,
headers
})
=>
{
.
then
(({
data
,
headers
})
=>
{
const
normalizedHeaders
=
normalizeHeaders
(
headers
);
const
normalizedHeaders
=
normalizeHeaders
(
headers
);
setPageTitle
(
decodeURI
(
normalizedHeaders
[
'
PAGE-TITLE
'
]));
setPageTitle
(
decodeURI
(
normalizedHeaders
[
'
PAGE-TITLE
'
]));
...
...
changelogs/unreleased/fix-ide-relative-url-bug.yml
0 → 100644
View file @
ee32e06f
---
title
:
Fix IDE get file data with '/' as relative root
merge_request
:
27911
author
:
type
:
fixed
spec/javascripts/ide/stores/actions/file_spec.js
View file @
ee32e06f
...
@@ -10,11 +10,19 @@ import eventHub from '~/ide/eventhub';
...
@@ -10,11 +10,19 @@ import eventHub from '~/ide/eventhub';
import
{
file
,
resetStore
}
from
'
../../helpers
'
;
import
{
file
,
resetStore
}
from
'
../../helpers
'
;
import
testAction
from
'
../../../helpers/vuex_action_helper
'
;
import
testAction
from
'
../../../helpers/vuex_action_helper
'
;
const
RELATIVE_URL_ROOT
=
'
/gitlab
'
;
describe
(
'
IDE store file actions
'
,
()
=>
{
describe
(
'
IDE store file actions
'
,
()
=>
{
let
mock
;
let
mock
;
let
originalGon
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mock
=
new
MockAdapter
(
axios
);
mock
=
new
MockAdapter
(
axios
);
originalGon
=
window
.
gon
;
window
.
gon
=
{
...
window
.
gon
,
relative_url_root
:
RELATIVE_URL_ROOT
,
};
spyOn
(
router
,
'
push
'
);
spyOn
(
router
,
'
push
'
);
});
});
...
@@ -22,6 +30,7 @@ describe('IDE store file actions', () => {
...
@@ -22,6 +30,7 @@ describe('IDE store file actions', () => {
afterEach
(()
=>
{
afterEach
(()
=>
{
mock
.
restore
();
mock
.
restore
();
resetStore
(
store
);
resetStore
(
store
);
window
.
gon
=
originalGon
;
});
});
describe
(
'
closeFile
'
,
()
=>
{
describe
(
'
closeFile
'
,
()
=>
{
...
@@ -173,13 +182,13 @@ describe('IDE store file actions', () => {
...
@@ -173,13 +182,13 @@ describe('IDE store file actions', () => {
spyOn
(
service
,
'
getFileData
'
).
and
.
callThrough
();
spyOn
(
service
,
'
getFileData
'
).
and
.
callThrough
();
localFile
=
file
(
`newCreate-
${
Math
.
random
()}
`
);
localFile
=
file
(
`newCreate-
${
Math
.
random
()}
`
);
localFile
.
url
=
`
${
gl
.
TEST_HOST
}
/getFileDataURL`
;
localFile
.
url
=
`
project
/getFileDataURL`
;
store
.
state
.
entries
[
localFile
.
path
]
=
localFile
;
store
.
state
.
entries
[
localFile
.
path
]
=
localFile
;
});
});
describe
(
'
success
'
,
()
=>
{
describe
(
'
success
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mock
.
onGet
(
`
${
gl
.
TEST_HOST
}
/getFileDataURL`
).
replyOnce
(
mock
.
onGet
(
`
${
RELATIVE_URL_ROOT
}
/project
/getFileDataURL`
).
replyOnce
(
200
,
200
,
{
{
blame_path
:
'
blame_path
'
,
blame_path
:
'
blame_path
'
,
...
@@ -200,7 +209,9 @@ describe('IDE store file actions', () => {
...
@@ -200,7 +209,9 @@ describe('IDE store file actions', () => {
store
store
.
dispatch
(
'
getFileData
'
,
{
path
:
localFile
.
path
})
.
dispatch
(
'
getFileData
'
,
{
path
:
localFile
.
path
})
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
service
.
getFileData
).
toHaveBeenCalledWith
(
`
${
gl
.
TEST_HOST
}
/getFileDataURL`
);
expect
(
service
.
getFileData
).
toHaveBeenCalledWith
(
`
${
RELATIVE_URL_ROOT
}
/project/getFileDataURL`
,
);
done
();
done
();
})
})
...
@@ -266,7 +277,7 @@ describe('IDE store file actions', () => {
...
@@ -266,7 +277,7 @@ describe('IDE store file actions', () => {
describe
(
'
error
'
,
()
=>
{
describe
(
'
error
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mock
.
onGet
(
`
${
gl
.
TEST_HOST
}
/getFileDataURL`
).
networkError
();
mock
.
onGet
(
`
project
/getFileDataURL`
).
networkError
();
});
});
it
(
'
dispatches error action
'
,
done
=>
{
it
(
'
dispatches error action
'
,
done
=>
{
...
...
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