Merge branch 'master' into better-change-detection

This commit is contained in:
Kim Gardner
2018-01-29 15:01:45 -05:00
committed by GitHub
2 changed files with 5 additions and 45 deletions
-40
View File
@@ -169,46 +169,6 @@ module.exports = class CommentsService {
created_at,
});
// We should adjust the comment's status such that if it was approved
// previously, we should mark the comment as 'NONE' or 'PREMOD', which ever
// was most recent if the new comment is destined to be `NONE` or `PREMOD`.
if (originalComment.status === 'ACCEPTED' && status === 'NONE') {
const lastUnmoderatedStatus = CommentsService.lastUnmoderatedStatus(
originalComment
);
// If the last moderated status was found and the current comment doesn't
// match this already.
if (lastUnmoderatedStatus && status !== lastUnmoderatedStatus) {
// Update the comment model (if at this point, the status is still
// accepted) with the previously unmoderated status
await CommentModel.update(
{
id,
status,
},
{
$set: {
status: lastUnmoderatedStatus,
},
$push: {
status_history: {
type: lastUnmoderatedStatus,
created_at,
},
},
}
);
// Update the returned comment.
editedComment.status = lastUnmoderatedStatus;
editedComment.status_history.push({
type: lastUnmoderatedStatus,
created_at,
});
}
}
await events.emitAsync(COMMENTS_EDIT, originalComment, editedComment);
return editedComment;
+5 -5
View File
@@ -227,12 +227,12 @@ describe('services.CommentsService', () => {
id: originalComment.id,
author_id: '123',
body: 'This is a body!',
status: 'NONE',
status: 'PREMOD',
});
expect(editedComment).to.have.property('status', 'PREMOD');
expect(editedComment.status_history).to.have.length(4);
expect(editedComment.status_history[3]).to.have.property(
expect(editedComment.status_history).to.have.length(3);
expect(editedComment.status_history[2]).to.have.property(
'type',
'PREMOD'
);
@@ -240,8 +240,8 @@ describe('services.CommentsService', () => {
retrivedComment = await CommentsService.findById(originalComment.id);
expect(retrivedComment).to.have.property('status', 'PREMOD');
expect(retrivedComment.status_history).to.have.length(4);
expect(retrivedComment.status_history[3]).to.have.property(
expect(retrivedComment.status_history).to.have.length(3);
expect(retrivedComment.status_history[2]).to.have.property(
'type',
'PREMOD'
);