Browse Source

improve unit format in emails

activeAddress
Ivan Socolsky 10 years ago
parent
commit
9c98502969
  1. 9
      lib/emailservice.js
  2. 4
      test/integration/server.js

9
lib/emailservice.js

@ -190,11 +190,18 @@ EmailService.prototype._getRecipientsList = function(notification, emailType, cb
EmailService.prototype._getDataForTemplate = function(notification, recipient, cb) {
var self = this;
// TODO: Declare these in BWU
var UNIT_LABELS = {
btc: 'BTC',
bit: 'bits'
};
var data = _.cloneDeep(notification.data);
data.subjectPrefix = _.trim(self.subjectPrefix) + ' ';
if (data.amount) {
try {
data.amount = WalletUtils.formatAmount(+data.amount, recipient.unit) + ' ' + recipient.unit;
var unit = recipient.unit.toLowerCase();
data.amount = WalletUtils.formatAmount(+data.amount, unit) + ' ' + UNIT_LABELS[unit];
} catch (ex) {
return cb(new Error('Could not format amount', ex));
}

4
test/integration/server.js

@ -607,14 +607,14 @@ describe('Wallet service', function() {
spanish.from.should.equal('bws@dummy.net');
spanish.subject.should.contain('Nuevo pago recibido');
spanish.text.should.contain(wallet.name);
spanish.text.should.contain('0.123 btc');
spanish.text.should.contain('0.123 BTC');
var english = _.find(emails, {
to: 'copayer2@domain.com'
});
english.from.should.equal('bws@dummy.net');
english.subject.should.contain('New payment received');
english.text.should.contain(wallet.name);
english.text.should.contain('123,000 bit');
english.text.should.contain('123,000 bits');
done();
}, 100);
});

Loading…
Cancel
Save