diff --git a/models/user.js b/models/user.js index d2adf6867..652383302 100644 --- a/models/user.js +++ b/models/user.js @@ -441,6 +441,7 @@ UserService.ban = (id, comment_id) => { .then(() => { // Set status of the user to banned return UserService.setStatus(id, 'banned').then(() => { + // Only if it was rejected based on a specific comment. // Reject the comment that the user was ban for. return Comment.setStatus(comment_id, 'rejected'); }); diff --git a/tests/models/user.js b/tests/models/user.js index cd3b67e7c..76024fc67 100644 --- a/tests/models/user.js +++ b/tests/models/user.js @@ -123,5 +123,19 @@ describe('User: models', () => { }); }); }); + + it('should not still disable and ban the user if there is no comment', () => { + return User + .ban(mockUsers[0].id, '') + .then(() => { + User.findById(mockUsers[0].id) + .then((user) => { + expect(user).to.have.property('status') + .and.to.equal('banned'); + expect(user).to.have.property('disabled') + .and.to.equal(true); + }); + }); + }); }); });