summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Mishunov <dmishunov@gitlab.com>2019-07-19 13:18:31 +0200
committerDenys Mishunov <dmishunov@gitlab.com>2019-07-19 14:36:18 +0200
commitcd638abbbf86e3129112b4c4066c094061023118 (patch)
treed368e240334a634d5cf3caee6e04d54ab75d1bb3
parent9f70a03b44b117242d6a1de04dfc6e4e43797633 (diff)
downloadgitlab-ce-64784-re-name-regression.tar.gz
Fixed regression for re-naming files in WebIDE64784-re-name-regression
-rw-r--r--app/assets/javascripts/ide/stores/mutations/file.js12
-rw-r--r--spec/javascripts/ide/stores/mutations/file_spec.js37
2 files changed, 45 insertions, 4 deletions
diff --git a/app/assets/javascripts/ide/stores/mutations/file.js b/app/assets/javascripts/ide/stores/mutations/file.js
index a52f1e235ed..1442ea7dbfa 100644
--- a/app/assets/javascripts/ide/stores/mutations/file.js
+++ b/app/assets/javascripts/ide/stores/mutations/file.js
@@ -43,10 +43,14 @@ export default {
[stateEntry, stagedFile, openFile, changedFile].forEach(f => {
if (f) {
- Object.assign(f, convertObjectPropsToCamelCase(data, { dropKeys: ['raw', 'baseRaw'] }), {
- raw: (stateEntry && stateEntry.raw) || null,
- baseRaw: null,
- });
+ Object.assign(
+ f,
+ convertObjectPropsToCamelCase(data, { dropKeys: ['path', 'name', 'raw', 'baseRaw'] }),
+ {
+ raw: (stateEntry && stateEntry.raw) || null,
+ baseRaw: null,
+ },
+ );
}
});
},
diff --git a/spec/javascripts/ide/stores/mutations/file_spec.js b/spec/javascripts/ide/stores/mutations/file_spec.js
index 7714f66c9a4..1b41c3c2548 100644
--- a/spec/javascripts/ide/stores/mutations/file_spec.js
+++ b/spec/javascripts/ide/stores/mutations/file_spec.js
@@ -103,6 +103,43 @@ describe('IDE store file mutations', () => {
expect(localState.openFiles[0].rawPath).toEqual(rawPath);
expect(localFile.rawPath).toEqual(rawPath);
});
+
+ it('does not mutate certain props on the file', () => {
+ const path = 'New Path';
+ const name = 'New Name';
+ localFile.path = path;
+ localFile.name = name;
+
+ localState.stagedFiles = [localFile];
+ localState.changedFiles = [localFile];
+ localState.openFiles = [localFile];
+
+ mutations.SET_FILE_DATA(localState, {
+ data: {
+ path: 'Old Path',
+ name: 'Old Name',
+ raw: 'Old Raw',
+ base_raw: 'Old Base Raw',
+ },
+ file: localFile,
+ });
+
+ [
+ localState.stagedFiles[0],
+ localState.changedFiles[0],
+ localState.openFiles[0],
+ localFile,
+ ].forEach(f => {
+ expect(f).toEqual(
+ jasmine.objectContaining({
+ path,
+ name,
+ raw: null,
+ baseRaw: null,
+ }),
+ );
+ });
+ });
});
describe('SET_FILE_RAW_DATA', () => {