diff options
-rw-r--r-- | service/pixelated/adapter/mailstore/leap_mailstore.py | 7 | ||||
-rw-r--r-- | web-ui/app/js/mail_view/ui/mail_view.js | 2 | ||||
-rw-r--r-- | web-ui/test/spec/mail_view/ui/mail_view.spec.js | 10 | ||||
-rw-r--r-- | web-ui/test/test_data.js | 29 |
4 files changed, 42 insertions, 6 deletions
diff --git a/service/pixelated/adapter/mailstore/leap_mailstore.py b/service/pixelated/adapter/mailstore/leap_mailstore.py index a8fa6d13..a9fb5ba1 100644 --- a/service/pixelated/adapter/mailstore/leap_mailstore.py +++ b/service/pixelated/adapter/mailstore/leap_mailstore.py @@ -26,11 +26,10 @@ from pixelated.adapter.model.mail import Mail, InputMail class AttachmentInfo(object): - def __init__(self, ident, name, encoding, headers): + def __init__(self, ident, name, encoding): self.ident = ident self.name = name self.encoding = encoding - self.headers = headers class LeapMail(Mail): @@ -99,7 +98,7 @@ class LeapMail(Mail): 'textPlainBody': self._body, 'replying': self._replying_dict(), 'mailbox': self._mailbox_name.lower(), - 'attachments': [{'ident': attachment.ident, 'name': attachment.name, 'encoding': attachment.encoding, 'headers': attachment.headers} for attachment in self._attachments] + 'attachments': [{'ident': attachment.ident, 'name': attachment.name, 'encoding': attachment.encoding} for attachment in self._attachments] } def _replying_dict(self): @@ -311,7 +310,7 @@ class LeapMailStore(MailStore): if 'attachment' in disposition: filename = _extract_filename(disposition) encoding = headers['Content-Transfer-Encoding'] - result.append(AttachmentInfo(phash, filename, encoding, headers)) + result.append(AttachmentInfo(phash, filename, encoding)) return result diff --git a/web-ui/app/js/mail_view/ui/mail_view.js b/web-ui/app/js/mail_view/ui/mail_view.js index 71a67e5a..7caf813a 100644 --- a/web-ui/app/js/mail_view/ui/mail_view.js +++ b/web-ui/app/js/mail_view/ui/mail_view.js @@ -58,7 +58,7 @@ define( } var attachments = _.map(data.mail.attachments, function(a){ - return { 'encoding': a.headers['Content-Transfer-Encoding'], 'name': a.name, 'ident': a.ident }; + return { 'encoding': a.encoding, 'name': a.name, 'ident': a.ident }; }); this.$node.html(templates.mails.fullView({ diff --git a/web-ui/test/spec/mail_view/ui/mail_view.spec.js b/web-ui/test/spec/mail_view/ui/mail_view.spec.js index deb7fb88..fe763919 100644 --- a/web-ui/test/spec/mail_view/ui/mail_view.spec.js +++ b/web-ui/test/spec/mail_view/ui/mail_view.spec.js @@ -265,6 +265,16 @@ describeComponent('mail_view/ui/mail_view', function () { expect(openNoMessageSelectedEvent).toHaveBeenTriggeredOn(document); }); + it('shows a download link for attachments', function() { + var withAttachments = {mail: Pixelated.testData().parsedMail.withAttachments}; + + this.component.displayMail({}, withAttachments); + + var attachmentLink = $(this.component.$node.find('.attachmentsArea li').html()); + var expectedLink = '/attachment/912ec803b2ce49e4a541068d495ab570?encoding=base64&filename=filename.txt'; + expect(attachmentLink.attr('href')) .toBe(expectedLink); + }); + function creatingEvent(event, keyCode) { var e = $.Event(event); e.which = keyCode; diff --git a/web-ui/test/test_data.js b/web-ui/test/test_data.js index 446fd7c6..62492bbe 100644 --- a/web-ui/test/test_data.js +++ b/web-ui/test/test_data.js @@ -202,6 +202,32 @@ define(function() { getMailPartByContentType: function () { return; } }; + var withAttachments = { + header: { + to:'jed_waelchi@cummerata.info', + from:'laurel@hamill.info', + subject:'Velit aut tempora animi ut nulla esse.', + date:'2014-06-04T14:41:13-03:00' + }, + ident:1, + tags:['textplain'], + mailbox: ['inbox'], + status:[], + textPlainBody: 'Hello Everyone', + isSentMail: function() { return false; }, + isDraftMail: function() { return false; }, + replyToAddress: function() { return { to: ['laurel@hamill.info'], cc: [] }; }, + replyToAllAddress: function() { return { to: ['laurel@hamill.info'], cc: [] }; }, + isMailMultipartAlternative: function() { return false; }, + availableBodyPartsContentType: function() { return []; }, + getMailPartByContentType: function() { return; }, + attachments: [{ + ident: '912ec803b2ce49e4a541068d495ab570', + name: 'filename.txt', + encoding: 'base64' + }] + }; + var testData = { rawMail: { mail: rawMail, @@ -215,7 +241,8 @@ define(function() { parsedMail: { simpleTextPlain: simpleTextPlainMail, html: htmlNoEncodingMail, - draft: draftMail + draft: draftMail, + withAttachments: withAttachments } }; |