Commit 563a7580 authored by Jiaan Louw's avatar Jiaan Louw Committed by Jose Ivan Vargas

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

parent 4936d09d
......@@ -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