Skip to content

Node.js based forum software built for the modern web

2 diff test

Barış Soner Uşaklı4504bbae5221
diff --git a/src/posts/diffs.js b/src/posts/diffs.js
index 6efaabcfb9..deec210619 100644
--- a/src/posts/diffs.js
+++ b/src/posts/diffs.js
@@ -23,7 +23,9 @@ Diffs.exists = function (pid, callback) {
Diffs.get = function (pid, since, callback) {
async.waterfall([
- async.apply(db.getListRange.bind(db), 'post:' + pid + ':diffs', 0, -1),
+ function (next) {
+ Diffs.list(pid, next);
+ },
function (timestamps, next) {
// Pass those made after `since`, and create keys
const keys = timestamps.filter(function (timestamp) {
diff --git a/test/posts.js b/test/posts.js
index f6b2c28261..6401d35bc0 100644
--- a/test/posts.js
+++ b/test/posts.js
@@ -443,6 +443,24 @@ describe('Post\'s', function () {
done();
});
});
+
+ it('should return diffs', function (done) {
+ posts.diffs.get(replyPid, 0, function (err, data) {
+ assert.ifError(err);
+ assert(Array.isArray(data));
+ assert(data[0].pid, replyPid);
+ assert(data[0].patch);
+ done();
+ });
+ });
+
+ it('should load diffs and reconstruct post', function (done) {
+ posts.diffs.load(replyPid, 0, voterUid, function (err, data) {
+ assert.ifError(err);
+ assert.equal(data.content, 'A reply to edit\n');
+ done();
+ });
+ });
});
describe('move', function () {