Commit 10dcaea1 authored by Phil Hughes's avatar Phil Hughes

failing spec fixes

parent 389c852d
......@@ -13,7 +13,7 @@
},
data() {
return {
entryName: '',
entryName: RepoStore.path !== '' ? `${RepoStore.path}/` : '',
};
},
components: {
......@@ -30,6 +30,8 @@
const dirNames = this.entryName.split('/');
dirNames.forEach((dirName) => {
if (dirName === '') return;
tree = RepoHelper.findOrCreateEntry('tree', tree, dirName).entry;
});
}
......
......@@ -16,35 +16,28 @@ const RepoEditor = {
},
mounted() {
if (!this.activeFile.tempFile) {
Service.getRaw(this.activeFile.raw_path)
.then((rawResponse) => {
Store.blobRaw = rawResponse.data;
Store.activeFile.plain = rawResponse.data;
this.createMonacoInstance();
})
.catch(Helper.loadingError);
} else {
this.createMonacoInstance();
}
},
Service.getRaw(this.activeFile)
.then((rawResponse) => {
Store.blobRaw = rawResponse.data;
Store.activeFile.plain = rawResponse.data;
const monacoInstance = Helper.monaco.editor.create(this.$el, {
model: null,
readOnly: false,
contextmenu: true,
scrollBeyondLastLine: false,
});
methods: {
createMonacoInstance() {
const monacoInstance = Helper.monaco.editor.create(this.$el, {
model: null,
readOnly: false,
contextmenu: true,
scrollBeyondLastLine: false,
});
Helper.monacoInstance = monacoInstance;
Helper.monacoInstance = monacoInstance;
this.addMonacoEvents();
this.addMonacoEvents();
this.setupEditor();
})
.catch(Helper.loadingError);
},
this.setupEditor();
},
methods: {
setupEditor() {
this.showHide();
......
......@@ -110,7 +110,7 @@ const RepoHelper = {
RepoHelper.setBinaryDataAsBase64(data);
Store.setViewToPreview();
} else if (!Store.isPreviewView() && !data.render_error) {
Service.getRaw(data.raw_path)
Service.getRaw(data)
.then((rawResponse) => {
Store.blobRaw = rawResponse.data;
data.plain = rawResponse.data;
......
......@@ -12,8 +12,14 @@ const RepoService = {
},
richExtensionRegExp: /md/,
getRaw(url) {
return axios.get(url, {
getRaw(file) {
if (file.tempFile) {
return Promise.resolve({
data: '',
});
}
return axios.get(file.raw_path, {
// Stop Axios from parsing a JSON file into a JS object
transformResponse: [res => res],
});
......
......@@ -77,7 +77,7 @@ const RepoStore = {
} else if (file.newContent || file.plain) {
RepoStore.blobRaw = file.newContent || file.plain;
} else if (!file.tempFile) {
Service.getRaw(file.raw_path)
Service.getRaw(file)
.then((rawResponse) => {
RepoStore.blobRaw = rawResponse.data;
Helper.findOpenedFileFromActive().plain = rawResponse.data;
......
......@@ -2,7 +2,16 @@ import Vue from 'vue';
import repoFileButtons from '~/repo/components/repo_file_buttons.vue';
import RepoStore from '~/repo/stores/repo_store';
describe('RepoFileButtons', () => {
fdescribe('RepoFileButtons', () => {
const activeFile = {
extension: 'md',
url: 'url',
raw_path: 'raw_path',
blame_path: 'blame_path',
commits_path: 'commits_path',
permalink: 'permalink',
};
function createComponent() {
const RepoFileButtons = Vue.extend(repoFileButtons);
......@@ -14,14 +23,6 @@ describe('RepoFileButtons', () => {
});
it('renders Raw, Blame, History, Permalink and Preview toggle', () => {
const activeFile = {
extension: 'md',
url: 'url',
raw_path: 'raw_path',
blame_path: 'blame_path',
commits_path: 'commits_path',
permalink: 'permalink',
};
const activeFileLabel = 'activeFileLabel';
RepoStore.openedFiles = new Array(1);
RepoStore.activeFile = activeFile;
......@@ -46,10 +47,6 @@ describe('RepoFileButtons', () => {
});
it('triggers rawPreviewToggle on preview click', () => {
const activeFile = {
extension: 'md',
url: 'url',
};
RepoStore.openedFiles = new Array(1);
RepoStore.activeFile = activeFile;
RepoStore.editMode = true;
......@@ -65,10 +62,7 @@ describe('RepoFileButtons', () => {
});
it('does not render preview toggle if not canPreview', () => {
const activeFile = {
extension: 'abcd',
url: 'url',
};
activeFile.extension = 'js';
RepoStore.openedFiles = new Array(1);
RepoStore.activeFile = activeFile;
......
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