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
563a7580
Commit
563a7580
authored
Apr 14, 2021
by
Jiaan Louw
Committed by
Jose Ivan Vargas
Apr 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Api.getRawFile to make ref param optional[RUN-AS-IF-FOSS]
parent
4936d09d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
3 deletions
+16
-3
app/assets/javascripts/api.js
app/assets/javascripts/api.js
+1
-1
ee/app/assets/javascripts/groups/settings/compliance_frameworks/utils.js
...avascripts/groups/settings/compliance_frameworks/utils.js
+1
-1
spec/frontend/api_spec.js
spec/frontend/api_spec.js
+14
-1
No files found.
app/assets/javascripts/api.js
View file @
563a7580
...
@@ -796,7 +796,7 @@ const Api = {
...
@@ -796,7 +796,7 @@ const Api = {
return
axios
.
delete
(
url
,
{
data
});
return
axios
.
delete
(
url
,
{
data
});
},
},
getRawFile
(
id
,
path
,
params
=
{
ref
:
'
master
'
})
{
getRawFile
(
id
,
path
,
params
=
{})
{
const
url
=
Api
.
buildUrl
(
this
.
rawFilePath
)
const
url
=
Api
.
buildUrl
(
this
.
rawFilePath
)
.
replace
(
'
:id
'
,
encodeURIComponent
(
id
))
.
replace
(
'
:id
'
,
encodeURIComponent
(
id
))
.
replace
(
'
:path
'
,
encodeURIComponent
(
path
));
.
replace
(
'
:path
'
,
encodeURIComponent
(
path
));
...
...
ee/app/assets/javascripts/groups/settings/compliance_frameworks/utils.js
View file @
563a7580
...
@@ -45,7 +45,7 @@ export const fetchPipelineConfigurationFileExists = async (path) => {
...
@@ -45,7 +45,7 @@ export const fetchPipelineConfigurationFileExists = async (path) => {
}
}
try
{
try
{
const
{
status
}
=
await
Api
.
getRawFile
(
`
${
group
}
/
${
project
}
`
,
file
,
{
ref
:
undefined
}
);
const
{
status
}
=
await
Api
.
getRawFile
(
`
${
group
}
/
${
project
}
`
,
file
);
return
status
===
httpStatus
.
OK
;
return
status
===
httpStatus
.
OK
;
}
catch
(
e
)
{
}
catch
(
e
)
{
...
...
spec/frontend/api_spec.js
View file @
563a7580
...
@@ -1222,13 +1222,26 @@ describe('Api', () => {
...
@@ -1222,13 +1222,26 @@ describe('Api', () => {
)}
/repository/files/
${
encodeURIComponent
(
dummyFilePath
)}
/raw`
;
)}
/repository/files/
${
encodeURIComponent
(
dummyFilePath
)}
/raw`
;
describe
(
'
when the raw file is successfully fetched
'
,
()
=>
{
describe
(
'
when the raw file is successfully fetched
'
,
()
=>
{
it
(
'
resolves the Promise
'
,
()
=>
{
beforeEach
(
()
=>
{
mock
.
onGet
(
expectedUrl
).
replyOnce
(
httpStatus
.
OK
);
mock
.
onGet
(
expectedUrl
).
replyOnce
(
httpStatus
.
OK
);
});
it
(
'
resolves the Promise
'
,
()
=>
{
return
Api
.
getRawFile
(
dummyProjectPath
,
dummyFilePath
).
then
(()
=>
{
return
Api
.
getRawFile
(
dummyProjectPath
,
dummyFilePath
).
then
(()
=>
{
expect
(
mock
.
history
.
get
).
toHaveLength
(
1
);
expect
(
mock
.
history
.
get
).
toHaveLength
(
1
);
});
});
});
});
describe
(
'
when the method is called with params
'
,
()
=>
{
it
(
'
sets the params on the request
'
,
()
=>
{
const
params
=
{
ref
:
'
main
'
};
jest
.
spyOn
(
axios
,
'
get
'
);
Api
.
getRawFile
(
dummyProjectPath
,
dummyFilePath
,
params
);
expect
(
axios
.
get
).
toHaveBeenCalledWith
(
expectedUrl
,
{
params
});
});
});
});
});
describe
(
'
when an error occurs while getting a raw file
'
,
()
=>
{
describe
(
'
when an error occurs while getting a raw file
'
,
()
=>
{
...
...
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