Commit 18766f4c authored by Thomas Randolph's avatar Thomas Randolph Committed by Phil Hughes

Convert vestigial "SET_DIFF_DATA" to "SET_DIFF_METADATA"

parent 27da16c9
......@@ -185,11 +185,11 @@ export const fetchDiffFilesMeta = ({ commit, state }) => {
.get(mergeUrlParams(urlParams, state.endpointMetadata))
.then(({ data }) => {
const strippedData = { ...data };
delete strippedData.diff_files;
commit(types.SET_LOADING, false);
commit(types.SET_MERGE_REQUEST_DIFFS, data.merge_request_diffs || []);
commit(types.SET_DIFF_DATA, strippedData);
commit(types.SET_DIFF_METADATA, strippedData);
worker.postMessage(prepareDiffData(data, state.diffFiles));
......
......@@ -3,7 +3,7 @@ export const SET_LOADING = 'SET_LOADING';
export const SET_BATCH_LOADING = 'SET_BATCH_LOADING';
export const SET_RETRIEVING_BATCHES = 'SET_RETRIEVING_BATCHES';
export const SET_DIFF_DATA = 'SET_DIFF_DATA';
export const SET_DIFF_METADATA = 'SET_DIFF_METADATA';
export const SET_DIFF_DATA_BATCH = 'SET_DIFF_DATA_BATCH';
export const SET_DIFF_FILES = 'SET_DIFF_FILES';
......
......@@ -66,17 +66,10 @@ export default {
updateDiffFilesInState(state, files);
},
[types.SET_DIFF_DATA](state, data) {
let files = state.diffFiles;
if (window.location.search.indexOf('diff_id') !== -1 && data.diff_files) {
files = prepareDiffData(data, files);
}
[types.SET_DIFF_METADATA](state, data) {
Object.assign(state, {
...convertObjectPropsToCamelCase(data),
});
updateDiffFilesInState(state, files);
},
[types.SET_DIFF_DATA_BATCH](state, data) {
......
......@@ -249,7 +249,7 @@ describe('DiffsStoreActions', () => {
{ type: types.SET_LOADING, payload: true },
{ type: types.SET_LOADING, payload: false },
{ type: types.SET_MERGE_REQUEST_DIFFS, payload: diffMetadata.merge_request_diffs },
{ type: types.SET_DIFF_DATA, payload: noFilesData },
{ type: types.SET_DIFF_METADATA, payload: noFilesData },
],
[],
() => {
......
......@@ -67,24 +67,24 @@ describe('DiffsStoreMutations', () => {
});
});
describe('SET_DIFF_DATA', () => {
it('should not modify the existing state', () => {
describe('SET_DIFF_METADATA', () => {
it('should overwrite state with the camelCased data that is passed in', () => {
const state = {
diffFiles: [
{
content_sha: diffFileMockData.content_sha,
file_hash: diffFileMockData.file_hash,
[INLINE_DIFF_LINES_KEY]: [],
},
],
diffFiles: [],
};
const diffMock = {
diff_files: [diffFileMockData],
};
const metaMock = {
other_key: 'value',
};
mutations[types.SET_DIFF_DATA](state, diffMock);
mutations[types.SET_DIFF_METADATA](state, diffMock);
expect(state.diffFiles[0]).toEqual(diffFileMockData);
expect(state.diffFiles[0][INLINE_DIFF_LINES_KEY]).toEqual([]);
mutations[types.SET_DIFF_METADATA](state, metaMock);
expect(state.diffFiles[0]).toEqual(diffFileMockData);
expect(state.otherKey).toEqual('value');
});
});
......
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