Commit 1a5cb572 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch '327200-update-getrawfile-params' into 'master'

Update Api.getRawFile to make ref param optional[RUN-AS-IF-FOSS]

See merge request gitlab-org/gitlab!59238
parents 24e67427 563a7580
......@@ -796,7 +796,7 @@ const Api = {
return axios.delete(url, { data });
},
getRawFile(id, path, params = { ref: 'master' }) {
getRawFile(id, path, params = {}) {
const url = Api.buildUrl(this.rawFilePath)
.replace(':id', encodeURIComponent(id))
.replace(':path', encodeURIComponent(path));
......
......@@ -45,7 +45,7 @@ export const fetchPipelineConfigurationFileExists = async (path) => {
}
try {
const { status } = await Api.getRawFile(`${group}/${project}`, file, { ref: undefined });
const { status } = await Api.getRawFile(`${group}/${project}`, file);
return status === httpStatus.OK;
} catch (e) {
......
......@@ -1222,13 +1222,26 @@ describe('Api', () => {
)}/repository/files/${encodeURIComponent(dummyFilePath)}/raw`;
describe('when the raw file is successfully fetched', () => {
it('resolves the Promise', () => {
beforeEach(() => {
mock.onGet(expectedUrl).replyOnce(httpStatus.OK);
});
it('resolves the Promise', () => {
return Api.getRawFile(dummyProjectPath, dummyFilePath).then(() => {
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', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment