summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--web-ui/app/js/mail_view/ui/attachment_list.js6
-rw-r--r--web-ui/test/spec/mail_view/ui/attachment_list.spec.js22
2 files changed, 8 insertions, 20 deletions
diff --git a/web-ui/app/js/mail_view/ui/attachment_list.js b/web-ui/app/js/mail_view/ui/attachment_list.js
index eb515865..f0581c67 100644
--- a/web-ui/app/js/mail_view/ui/attachment_list.js
+++ b/web-ui/app/js/mail_view/ui/attachment_list.js
@@ -38,6 +38,9 @@ define(
uploadFileButton: '#upload-file-button'
});
+ var ONE_MEGABYTE = 1024*1024;
+ var ATTACHMENT_SIZE_LIMIT = ONE_MEGABYTE;
+
this.showAttachment = function (ev, data) {
this.trigger(document, events.mail.appendAttachment, data);
this.renderAttachmentListView(data);
@@ -89,8 +92,7 @@ define(
self.trigger(document, events.mail.startUploadAttachment);
};
- var ONE_MEGABYTE = 1000000;
- if (data.originalFiles[0].size > ONE_MEGABYTE) {
+ if (data.originalFiles[0].size > ATTACHMENT_SIZE_LIMIT) {
uploadErrors.push('Filesize is too big');
}
if (uploadErrors.length > 0) {
diff --git a/web-ui/test/spec/mail_view/ui/attachment_list.spec.js b/web-ui/test/spec/mail_view/ui/attachment_list.spec.js
index d0133bc5..20f82704 100644
--- a/web-ui/test/spec/mail_view/ui/attachment_list.spec.js
+++ b/web-ui/test/spec/mail_view/ui/attachment_list.spec.js
@@ -40,9 +40,10 @@ describeMixin('mail_view/ui/attachment_list', function () {
});
describe('Upload files -- max file size -- ', function (){
+ var ONE_MEGABYTE = 1024*1024;
var submitFile = 'file not submitted', submitted = 'file submitted';
var mockSubmit = function (){ submitFile = submitted; };
- var largeAttachment = {originalFiles: [{size: 4500000}], submit: mockSubmit};
+ var largeAttachment = {originalFiles: [{size: ONE_MEGABYTE+1}], submit: mockSubmit};
var dummyEvent = 'whatever, not used';
it('should show error messages on the dom, when uploading files larger than 1MB', function () {
@@ -85,27 +86,12 @@ describeMixin('mail_view/ui/attachment_list', function () {
expect(largeAttachment.submit).not.toHaveBeenCalled();
});
- it('should upload files smaller than 1MB', function () {
- var smallAttachment = {originalFiles: [{size: 450}], submit: mockSubmit};
+ it('should upload files less or equal 1MB', function () {
+ var smallAttachment = {originalFiles: [{size: ONE_MEGABYTE}], submit: mockSubmit};
this.component.checkAttachmentSize(dummyEvent, smallAttachment);
expect(submitFile).toEqual(submitted);
});
});
-
- xit('should start uploading attachments', function () {
- var stubAttachment = {ident: 'faked', name: 'haha.txt', size: 4500};
- var mockAjax = spyOn($, 'ajax').and.callFake(function (params) {params.success(stubAttachment);});
- var uploadedAttachment = spyOnEvent(document, Pixelated.events.mail.uploadedAttachment);
- var uploading = spyOnEvent(document, Pixelated.events.mail.uploadingAttachment);
-
- $(document).trigger(Pixelated.events.mail.startUploadAttachment);
-
- expect(mockAjax).toHaveBeenCalled();
- expect(uploadedAttachment).toHaveBeenTriggeredOnAndWith(document, stubAttachment);
- expect(uploading).toHaveBeenTriggeredOn(document);
- });
-
});
-
});