summaryrefslogtreecommitdiff
path: root/web-ui
diff options
context:
space:
mode:
authorJefferson Stachelski <jeffhsta@riseup.net>2016-02-12 17:58:45 -0200
committerJefferson Stachelski <jeffhsta@riseup.net>2016-02-12 17:58:45 -0200
commita9626c697992fcd596726a4c16ba8c9757f6a0dd (patch)
tree36461e71dada715b6bd1f59c311271f5a83f68b0 /web-ui
parente889bb5c34d4fcfa0f798134771e9dcb3ab062f6 (diff)
attachments are only un-linked from emails but not deleted in soledad
- removed backend delete of attachments - JS unit tests - Functional test Issue #549
Diffstat (limited to 'web-ui')
-rw-r--r--web-ui/app/js/mail_view/ui/attachment_list.js10
-rw-r--r--web-ui/test/spec/mail_view/ui/attachment_list.spec.js46
2 files changed, 48 insertions, 8 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 ff7602ec..0483ae6a 100644
--- a/web-ui/app/js/mail_view/ui/attachment_list.js
+++ b/web-ui/app/js/mail_view/ui/attachment_list.js
@@ -195,14 +195,8 @@ define(
};
this.removeAttachments = function(event, data) {
- var success = function() {
- this.removeAttachmentFromList(data);
- this.destroyAttachmentElement(data);
- };
-
- monitoredAjax(this, '/attachment/' + data.ident, {
- type: 'DELETE'
- }).done(success.bind(this));
+ this.removeAttachmentFromList(data);
+ this.destroyAttachmentElement(data);
};
this.after('initialize', function () {
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 94559b63..eab605d6 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
@@ -120,6 +120,52 @@ describeMixin('mail_view/ui/attachment_list', function () {
expect(uploadAccepted).toBe(true);
});
});
+
+ describe('Remove attachment', function () {
+ it('should call the remove attachment method when triggered the removeAttachement event', function () {
+ var stubAttachment = {ident: 'whatever'};
+ spyOn(this.component, 'removeAttachmentFromList');
+ spyOn(this.component, 'destroyAttachmentElement');
+
+ $(document).trigger(Pixelated.events.mail.removeAttachment, stubAttachment);
+
+ expect(this.component.removeAttachmentFromList).toHaveBeenCalledWith(stubAttachment);
+ expect(this.component.destroyAttachmentElement).toHaveBeenCalledWith(stubAttachment);
+ });
+
+ it('should remove the attachment item from the DOM', function () {
+ var stubAttachment = {ident: 'whatever'};
+ this.setupComponent('<div id="attachment-list">' +
+ '<ul id="attachment-list-item"><li data-ident="whatever"></li></ul>' +
+ '<ul id="attachment-upload-item"></ul>' +
+ '</div>');
+
+ expect(this.component.$node.find('li[data-ident=whatever]').length).toEqual(1);
+
+ this.component.destroyAttachmentElement(stubAttachment);
+
+ expect(this.component.$node.find('li[data-ident=whatever]').length).toEqual(0);
+ });
+
+
+ it('should remove attachment from attachment list', function () {
+ var stubAttachment = {ident: 'whatever'};
+ this.component.attr.attachments = [stubAttachment, {ident: 'another attachment'}];
+ this.component.removeAttachmentFromList(stubAttachment);
+
+ expect(this.component.attr.attachments).toEqual([{ident: 'another attachment'}]);
+ });
+
+
+ it('when remove attachment that is not on the attachment list should not do anything', function () {
+ var stubAttachment = {ident: 'whatever'};
+ this.component.attr.attachments = [stubAttachment];
+
+ this.component.removeAttachmentFromList({ident: 'different attachment'});
+
+ expect(this.component.attr.attachments).toEqual([stubAttachment]);
+ });
+ });
});
});
});