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