Merge pull request #527 from isocolsky/ref/empty-notes

Allow empty tx notes
This commit is contained in:
Matias Alejo Garcia 2016-06-07 09:19:53 -03:00
commit d8633065cd
2 changed files with 14 additions and 5 deletions

View File

@ -663,7 +663,7 @@ Storage.prototype.fetchTxNote = function(walletId, txid, cb) {
txid: txid,
}, function(err, result) {
if (err) return cb(err);
if (!result || !result.body) return cb();
if (!result) return cb();
return self._completeTxNotesData(walletId, Model.TxNote.fromObj(result), cb);
});
};
@ -699,7 +699,6 @@ Storage.prototype.fetchTxNotes = function(walletId, opts, cb) {
this.db.collection(collections.TX_NOTES).find(filter).toArray(function(err, result) {
if (err) return cb(err);
var notes = _.compact(_.map(result, function(note) {
if (!note.body) return;
return Model.TxNote.fromObj(note);
}));
return self._completeTxNotesData(walletId, notes, cb);

View File

@ -4058,7 +4058,7 @@ describe('Wallet service', function() {
});
});
});
it('should be possible to remove a note', function(done) {
it('should be possible to set an empty note', function(done) {
server.editTxNote({
txid: '123',
body: 'note body'
@ -4078,8 +4078,18 @@ describe('Wallet service', function() {
txid: '123',
}, function(err, note) {
should.not.exist(err);
should.not.exist(note);
done();
should.exist(note);
note.should.have.property('body');
should.equal(note.body, null);
server.getTxNotes({
minTs: 0
}, function(err, notes) {
should.not.exist(err);
should.exist(notes);
notes.length.should.equal(1);
should.equal(notes[0].body, null);
done();
});
});
});
});