From cac008662721abbb7ba470127e5ff192b581720d Mon Sep 17 00:00:00 2001 From: Felix Hammerl Date: Thu, 6 Mar 2014 18:02:05 +0100 Subject: [PATCH] add date to outbox --- src/js/controller/write.js | 3 ++- src/js/dao/devicestorage-dao.js | 2 -- test/new-unit/write-ctrl-test.js | 19 +++++++++++++++---- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/js/controller/write.js b/src/js/controller/write.js index 499f8fc..9b526d5 100644 --- a/src/js/controller/write.js +++ b/src/js/controller/write.js @@ -226,7 +226,8 @@ define(function(require) { bcc: $scope.bcc.filter(filterEmptyAddresses), subject: $scope.subject.trim() ? $scope.subject.trim() : str.fallbackSubject, // Subject line, or the fallback subject, if nothing valid was entered body: $scope.body.trim() + (!$scope.sendBtnSecure ? str.signature : ''), // use parsed plaintext body - attachments: $scope.attachments + attachments: $scope.attachments, + sentDate: new Date() }; // close the writer diff --git a/src/js/dao/devicestorage-dao.js b/src/js/dao/devicestorage-dao.js index b7e352b..9522ead 100644 --- a/src/js/dao/devicestorage-dao.js +++ b/src/js/dao/devicestorage-dao.js @@ -84,8 +84,6 @@ define(function() { // put uid in key if available... for easy querying if (i.uid) { key = type + '_' + i.uid; - } else if (i.sentDate && i.id) { - key = type + '_' + i.sentDate + '_' + i.id; } else if (i.id) { key = type + '_' + i.id; } else { diff --git a/test/new-unit/write-ctrl-test.js b/test/new-unit/write-ctrl-test.js index fd39ebd..25f2d92 100644 --- a/test/new-unit/write-ctrl-test.js +++ b/test/new-unit/write-ctrl-test.js @@ -272,9 +272,6 @@ define(function(require) { describe('send to outbox', function() { it('should work', function() { - scope.from = [{ - address: 'pity@dafool' - }]; scope.to = [{ address: 'pity@dafool' }]; @@ -289,7 +286,21 @@ define(function(require) { scope.replyTo = {}; - outboxMock.put.yields(); + outboxMock.put.withArgs(sinon.match(function(mail) { + expect(mail.from).to.deep.equal([{ + address: emailAddress + }]); + expect(mail.to).to.deep.equal(scope.to); + expect(mail.cc).to.deep.equal(scope.cc); + expect(mail.bcc).to.deep.equal(scope.bcc); + expect(mail.body).to.contain(scope.body); + expect(mail.subject).to.equal(scope.subject); + expect(mail.attachments).to.be.empty; + expect(mail.sentDate).to.exist; + + + return true; + })).yields(); emailDaoMock.sync.yields(); scope.onError = function(err) {