mirror of
https://github.com/wassname/talk.git
synced 2026-09-09 11:38:08 +08:00
Fix users and comments as a merge was weird before.
This commit is contained in:
+2
-18
@@ -30,19 +30,6 @@ const CommentSchema = new Schema({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//==============================================================================
|
|
||||||
// New Statics
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a comment.
|
|
||||||
* @param {String} body content of comment
|
|
||||||
*/
|
|
||||||
CommentSchema.statics.new = function(body, author_id, asset_id, parent_id, status, username) {
|
|
||||||
let comment = new Comment({body, author_id, asset_id, parent_id, status, username});
|
|
||||||
return comment.save();
|
|
||||||
};
|
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
// Find Statics
|
// Find Statics
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
@@ -159,16 +146,13 @@ CommentSchema.statics.moderationQueue = function(moderation) {
|
|||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes the status of a comment.
|
* Change the status of a comment.
|
||||||
* @param {String} id identifier of the comment (uuid)
|
* @param {String} id identifier of the comment (uuid)
|
||||||
* @param {String} status the new status of the comment
|
* @param {String} status the new status of the comment
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
CommentSchema.statics.changeStatus = function(id, status) {
|
CommentSchema.statics.changeStatus = function(id, status) {
|
||||||
return Comment.findOneAndUpdate({'id': id}, {$set: {'status': status}}, {upsert: false, new: true})
|
return Comment.findOneAndUpdate({'id': id}, {$set: {'status': status}});
|
||||||
.then((comment) => {
|
|
||||||
return comment;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
const User = require('../../models/user');
|
const User = require('../../models/user');
|
||||||
const Comment = require('../../models/comment');
|
const Comment = require('../../models/comment');
|
||||||
|
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
|
|
||||||
describe('User: models', () => {
|
describe('User: models', () => {
|
||||||
@@ -96,7 +97,9 @@ describe('User: models', () => {
|
|||||||
describe('#ban', () => {
|
describe('#ban', () => {
|
||||||
let mockComment;
|
let mockComment;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
return Comment.new('testing the comment for that user if it is rejected.', mockUsers[0].id)
|
return Promise.all([
|
||||||
|
Comment.create([{body: 'testing the comment for that user if it is rejected.', id: mockUsers[0].id}])
|
||||||
|
])
|
||||||
.then((comment) => {
|
.then((comment) => {
|
||||||
mockComment = comment;
|
mockComment = comment;
|
||||||
});
|
});
|
||||||
@@ -156,7 +159,9 @@ describe('User: models', () => {
|
|||||||
describe('#unban', () => {
|
describe('#unban', () => {
|
||||||
let mockComment;
|
let mockComment;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
return Comment.new('testing the comment for that user if it is rejected.', mockUsers[0].id)
|
return Promise.all([
|
||||||
|
Comment.create([{body: 'testing the comment for that user if it is rejected.', id: mockUsers[0].id}])
|
||||||
|
])
|
||||||
.then((comment) => {
|
.then((comment) => {
|
||||||
mockComment = comment;
|
mockComment = comment;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user