Loading comments/comments.js +7 −6 Original line number Diff line number Diff line Loading @@ -207,18 +207,19 @@ Comments.prototype = { }, /** * Marks comment as deleted. * Marks comment as deleted or not deleted. * * @param {Object} action A delete action: * @param {Number} action.id ID of the comment to delete. * @param {Number} action.user_id ID of the user doing the delete. * @param {Object} action An action config: * @param {Number} action.id ID of the comment. * @param {Number} action.user_id ID of the user doing the delete or undelete. * @param {Boolean} action.deleted True to delete, false to undo delete. * @param {Error} callback.err The error object. * @param {Function} callback Called when done. */ setDeleted: function(action, callback) { var data = { id: action.id, deleted: 1 deleted: action.deleted ? 1 : 0 }; this.db.update("comments", data, function(err) { if (err) { Loading @@ -228,7 +229,7 @@ Comments.prototype = { this.db.insert("updates", { comment_id: action.id, user_id: action.user_id, action: 'delete', action: action.deleted ? 'delete' : 'undo_delete', created_at: new Date() }, callback); }.bind(this)); Loading comments/comments.spec.js +11 −2 Original line number Diff line number Diff line Loading @@ -187,8 +187,8 @@ describe("Comments", function() { }); }); it("#setDeleted marks comment as deleted, so it can't be accessed any more", function(done) { comments.setDeleted({id: 10, user_id: 1}, function(err) { it("#setDeleted(true) marks comment as deleted, so it can't be accessed any more", function(done) { comments.setDeleted({deleted: true, id: 10, user_id: 1}, function(err) { comments.getById(10, function(err, newCom) { expect(newCom).toEqual(null); done(); Loading @@ -196,4 +196,13 @@ describe("Comments", function() { }); }); it("#setDeleted(false) undoes the delete, so comment can be accessed again", function(done) { comments.setDeleted({deleted: false, id: 10, user_id: 1}, function(err) { comments.getById(10, function(err, newCom) { expect(newCom).not.toEqual(null); done(); }); }); }); }); Loading
comments/comments.js +7 −6 Original line number Diff line number Diff line Loading @@ -207,18 +207,19 @@ Comments.prototype = { }, /** * Marks comment as deleted. * Marks comment as deleted or not deleted. * * @param {Object} action A delete action: * @param {Number} action.id ID of the comment to delete. * @param {Number} action.user_id ID of the user doing the delete. * @param {Object} action An action config: * @param {Number} action.id ID of the comment. * @param {Number} action.user_id ID of the user doing the delete or undelete. * @param {Boolean} action.deleted True to delete, false to undo delete. * @param {Error} callback.err The error object. * @param {Function} callback Called when done. */ setDeleted: function(action, callback) { var data = { id: action.id, deleted: 1 deleted: action.deleted ? 1 : 0 }; this.db.update("comments", data, function(err) { if (err) { Loading @@ -228,7 +229,7 @@ Comments.prototype = { this.db.insert("updates", { comment_id: action.id, user_id: action.user_id, action: 'delete', action: action.deleted ? 'delete' : 'undo_delete', created_at: new Date() }, callback); }.bind(this)); Loading
comments/comments.spec.js +11 −2 Original line number Diff line number Diff line Loading @@ -187,8 +187,8 @@ describe("Comments", function() { }); }); it("#setDeleted marks comment as deleted, so it can't be accessed any more", function(done) { comments.setDeleted({id: 10, user_id: 1}, function(err) { it("#setDeleted(true) marks comment as deleted, so it can't be accessed any more", function(done) { comments.setDeleted({deleted: true, id: 10, user_id: 1}, function(err) { comments.getById(10, function(err, newCom) { expect(newCom).toEqual(null); done(); Loading @@ -196,4 +196,13 @@ describe("Comments", function() { }); }); it("#setDeleted(false) undoes the delete, so comment can be accessed again", function(done) { comments.setDeleted({deleted: false, id: 10, user_id: 1}, function(err) { comments.getById(10, function(err, newCom) { expect(newCom).not.toEqual(null); done(); }); }); }); });