Commit 7aac4e5c authored by Ondřej Budai's avatar Ondřej Budai Committed by Phil Hughes

Fix whitespace changes visibility when the related file was initially collapsed

parent b560ce1e
...@@ -211,11 +211,12 @@ export const scrollToLineIfNeededParallel = (_, line) => { ...@@ -211,11 +211,12 @@ export const scrollToLineIfNeededParallel = (_, line) => {
} }
}; };
export const loadCollapsedDiff = ({ commit, getters }, file) => export const loadCollapsedDiff = ({ commit, getters, state }, file) =>
axios axios
.get(file.load_collapsed_diff_url, { .get(file.load_collapsed_diff_url, {
params: { params: {
commit_id: getters.commitId, commit_id: getters.commitId,
w: state.showWhitespace ? '0' : '1',
}, },
}) })
.then(res => { .then(res => {
......
---
title: Fix whitespace changes visibility when the related file was initially collapsed
merge_request: 28950
author: Ondřej Budai
type: fixed
...@@ -396,6 +396,7 @@ describe('DiffsStoreActions', () => { ...@@ -396,6 +396,7 @@ describe('DiffsStoreActions', () => {
}); });
describe('loadCollapsedDiff', () => { describe('loadCollapsedDiff', () => {
const state = { showWhitespace: true };
it('should fetch data and call mutation with response and the give parameter', done => { it('should fetch data and call mutation with response and the give parameter', done => {
const file = { hash: 123, load_collapsed_diff_url: '/load/collapsed/diff/url' }; const file = { hash: 123, load_collapsed_diff_url: '/load/collapsed/diff/url' };
const data = { hash: 123, parallelDiffLines: [{ lineCode: 1 }] }; const data = { hash: 123, parallelDiffLines: [{ lineCode: 1 }] };
...@@ -403,7 +404,7 @@ describe('DiffsStoreActions', () => { ...@@ -403,7 +404,7 @@ describe('DiffsStoreActions', () => {
const commit = jasmine.createSpy('commit'); const commit = jasmine.createSpy('commit');
mock.onGet(file.loadCollapsedDiffUrl).reply(200, data); mock.onGet(file.loadCollapsedDiffUrl).reply(200, data);
loadCollapsedDiff({ commit, getters: { commitId: null } }, file) loadCollapsedDiff({ commit, getters: { commitId: null }, state }, file)
.then(() => { .then(() => {
expect(commit).toHaveBeenCalledWith(types.ADD_COLLAPSED_DIFFS, { file, data }); expect(commit).toHaveBeenCalledWith(types.ADD_COLLAPSED_DIFFS, { file, data });
...@@ -421,10 +422,10 @@ describe('DiffsStoreActions', () => { ...@@ -421,10 +422,10 @@ describe('DiffsStoreActions', () => {
spyOn(axios, 'get').and.returnValue(Promise.resolve({ data: {} })); spyOn(axios, 'get').and.returnValue(Promise.resolve({ data: {} }));
loadCollapsedDiff({ commit() {}, getters }, file); loadCollapsedDiff({ commit() {}, getters, state }, file);
expect(axios.get).toHaveBeenCalledWith(file.load_collapsed_diff_url, { expect(axios.get).toHaveBeenCalledWith(file.load_collapsed_diff_url, {
params: { commit_id: null }, params: { commit_id: null, w: '0' },
}); });
}); });
...@@ -436,10 +437,10 @@ describe('DiffsStoreActions', () => { ...@@ -436,10 +437,10 @@ describe('DiffsStoreActions', () => {
spyOn(axios, 'get').and.returnValue(Promise.resolve({ data: {} })); spyOn(axios, 'get').and.returnValue(Promise.resolve({ data: {} }));
loadCollapsedDiff({ commit() {}, getters }, file); loadCollapsedDiff({ commit() {}, getters, state }, file);
expect(axios.get).toHaveBeenCalledWith(file.load_collapsed_diff_url, { expect(axios.get).toHaveBeenCalledWith(file.load_collapsed_diff_url, {
params: { commit_id: '123' }, params: { commit_id: '123', w: '0' },
}); });
}); });
}); });
......
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