1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-26 10:52:17 -05:00

Merge pull request #8 from whiteout-io/dev/outbox-offline

do not try to send when offline
This commit is contained in:
Tankred Hase 2014-01-20 02:06:24 -08:00
commit 647a248717
2 changed files with 30 additions and 1 deletions

View File

@ -112,6 +112,13 @@ define(function(require) {
self.pendingEmails.push(i);
});
// we're not online, don't even bother sending mails
if (!self._emailDao._account.online) {
self._outboxBusy = false;
callback(null, self.pendingEmails.length);
return;
}
// sending pending mails
processMails();
});

View File

@ -19,7 +19,8 @@ define(function(require) {
emailAddress: dummyUser,
folders: [{
type: 'Outbox'
}]
}],
online: true
};
devicestorageStub = sinon.createStubInstance(DeviceStorageDAO);
keychainStub = sinon.createStubInstance(KeychainDAO);
@ -107,6 +108,8 @@ define(function(require) {
})).yieldsAsync();
var check = _.after(dummyMails.length + 1, function() {
expect(outbox._outboxBusy).to.be.false;
expect(unsentCount).to.equal(2);
expect(emailDaoStub.list.callCount).to.equal(1);
expect(emailDaoStub.sendEncrypted.callCount).to.equal(1);
@ -131,6 +134,25 @@ define(function(require) {
outbox._processOutbox(onOutboxUpdate);
});
it('should not process outbox in offline mode', function(done) {
emailDaoStub._account.online = false;
emailDaoStub.list.yieldsAsync(null, [{
id: '123',
to: [{
name: 'member',
address: 'member@whiteout.io'
}]
}]);
outbox._processOutbox(function(err, count) {
expect(err).to.not.exist;
expect(count).to.equal(1);
expect(emailDaoStub.list.callCount).to.equal(1);
expect(outbox._outboxBusy).to.be.false;
done();
});
});
it('should fire notification', function(done) {
outbox.onSent = function(email) {
expect(email).to.exist;