Commit f1a2ada1 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'ide-mr-open-file-fix' into 'master'

Fixed none merge request files not being openable in the web IDE

See merge request gitlab-org/gitlab-ce!18881
parents 95bb2a4f a769e1ed
...@@ -140,7 +140,7 @@ export default { ...@@ -140,7 +140,7 @@ export default {
this.file.staged && this.file.key.indexOf('unstaged-') === 0 ? head : null, this.file.staged && this.file.key.indexOf('unstaged-') === 0 ? head : null,
); );
if (this.viewer === viewerTypes.mr) { if (this.viewer === viewerTypes.mr && this.file.mrChange) {
this.editor.attachMergeRequestModel(this.model); this.editor.attachMergeRequestModel(this.model);
} else { } else {
this.editor.attachModel(this.model); this.editor.attachModel(this.model);
......
...@@ -44,6 +44,7 @@ export const dataStructure = () => ({ ...@@ -44,6 +44,7 @@ export const dataStructure = () => ({
size: 0, size: 0,
parentPath: null, parentPath: null,
lastOpenedAt: 0, lastOpenedAt: 0,
mrChange: null,
}); });
export const decorateData = entity => { export const decorateData = entity => {
......
...@@ -24,7 +24,7 @@ describe('RepoEditor', () => { ...@@ -24,7 +24,7 @@ describe('RepoEditor', () => {
f.active = true; f.active = true;
f.tempFile = true; f.tempFile = true;
vm.$store.state.openFiles.push(f); vm.$store.state.openFiles.push(f);
vm.$store.state.entries[f.path] = f; Vue.set(vm.$store.state.entries, f.path, f);
vm.monaco = true; vm.monaco = true;
vm.$mount(); vm.$mount();
...@@ -215,6 +215,30 @@ describe('RepoEditor', () => { ...@@ -215,6 +215,30 @@ describe('RepoEditor', () => {
expect(vm.editor.attachModel).toHaveBeenCalledWith(vm.model); expect(vm.editor.attachModel).toHaveBeenCalledWith(vm.model);
}); });
it('attaches model to merge request editor', () => {
vm.$store.state.viewer = 'mrdiff';
vm.file.mrChange = true;
spyOn(vm.editor, 'attachMergeRequestModel');
Editor.editorInstance.modelManager.dispose();
vm.setupEditor();
expect(vm.editor.attachMergeRequestModel).toHaveBeenCalledWith(vm.model);
});
it('does not attach model to merge request editor when not a MR change', () => {
vm.$store.state.viewer = 'mrdiff';
vm.file.mrChange = false;
spyOn(vm.editor, 'attachMergeRequestModel');
Editor.editorInstance.modelManager.dispose();
vm.setupEditor();
expect(vm.editor.attachMergeRequestModel).not.toHaveBeenCalledWith(vm.model);
});
it('adds callback methods', () => { it('adds callback methods', () => {
spyOn(vm.editor, 'onPositionChange').and.callThrough(); spyOn(vm.editor, 'onPositionChange').and.callThrough();
......
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