From fe2f0a7d10f71e05550036e896d8bcc653644b57 Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Tue, 7 Jun 2016 09:15:28 -0300 Subject: [PATCH] allow empty notes --- lib/storage.js | 3 +-- test/integration/server.js | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/storage.js b/lib/storage.js index 7f044ef..426f8a7 100644 --- a/lib/storage.js +++ b/lib/storage.js @@ -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); diff --git a/test/integration/server.js b/test/integration/server.js index 57b5f9e..fb35332 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -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(); + }); }); }); });