Merge branch 'ide-multiple-file-uploads' into 'master'

Enabled multiple uploads in the Web IDE

Closes #50405

See merge request gitlab-org/gitlab-ce!21412
This commit is contained in:
Filipa Lacerda 2018-08-30 16:57:18 +00:00
commit 9c491bc628
3 changed files with 24 additions and 6 deletions

View File

@ -24,12 +24,6 @@ export default {
default: null,
},
},
mounted() {
this.$refs.fileUpload.addEventListener('change', this.openFile);
},
beforeDestroy() {
this.$refs.fileUpload.removeEventListener('change', this.openFile);
},
methods: {
createFile(target, file, isText) {
const { name } = file;
@ -85,6 +79,8 @@ export default {
ref="fileUpload"
type="file"
class="hidden"
multiple
@change="openFile"
/>
</div>
</template>

View File

@ -0,0 +1,5 @@
---
title: Enabled multiple file uploads in the Web IDE
merge_request:
author:
type: added

View File

@ -21,6 +21,23 @@ describe('new dropdown upload', () => {
vm.$destroy();
});
describe('openFile', () => {
it('calls for each file', () => {
const files = ['test', 'test2', 'test3'];
spyOn(vm, 'readFile');
spyOnProperty(vm.$refs.fileUpload, 'files').and.returnValue(files);
vm.openFile();
expect(vm.readFile.calls.count()).toBe(3);
files.forEach((file, i) => {
expect(vm.readFile.calls.argsFor(i)).toEqual([file]);
});
});
});
describe('readFile', () => {
beforeEach(() => {
spyOn(FileReader.prototype, 'readAsText');