diff --git a/client/coral-admin/src/actions/comments.js b/client/coral-admin/src/actions/comments.js
index 2dae1ef00..f37c79b4f 100644
--- a/client/coral-admin/src/actions/comments.js
+++ b/client/coral-admin/src/actions/comments.js
@@ -55,6 +55,10 @@ export const fetchFlaggedQueue = () => {
dispatch({type: commentTypes.COMMENTS_MODERATION_QUEUE_FETCH_REQUEST});
return coralApi('/queue/comments/flagged')
+ .then(comments => {
+ comments.forEach(comment => comment.flagged = true);
+ return comments;
+ })
.then(addUsersCommentsActions.bind(this, dispatch));
};
};
diff --git a/client/coral-admin/src/containers/ModerationQueue/ModerationQueue.js b/client/coral-admin/src/containers/ModerationQueue/ModerationQueue.js
index 55a2e705e..d46a9b35d 100644
--- a/client/coral-admin/src/containers/ModerationQueue/ModerationQueue.js
+++ b/client/coral-admin/src/containers/ModerationQueue/ModerationQueue.js
@@ -56,7 +56,7 @@ export default ({onTabClick, ...props}) => (
{
if (charCountEnable && body.length > charCount) {
return 'rejected';
}
- return moderation === 'pre' ? 'premod' : '';
+ return moderation === 'pre' ? 'premod' : null;
});
}
diff --git a/routes/api/queue/index.js b/routes/api/queue/index.js
index ff9e31d76..34902557c 100644
--- a/routes/api/queue/index.js
+++ b/routes/api/queue/index.js
@@ -68,6 +68,7 @@ router.get('/comments/flagged', authorization.needed('admin'), (req, res, next)
.then(ids => assetIDWrap(Comment.find({
id: {$in: ids}
})))
+ .then(gatherActionsAndUsers)
.then(([comments, users, actions]) => {
res.json({comments, users, actions});
})
diff --git a/tests/models/comment.js b/tests/models/comment.js
index 91f51ccb8..20590dc3d 100644
--- a/tests/models/comment.js
+++ b/tests/models/comment.js
@@ -21,6 +21,7 @@ describe('models.Comment', () => {
status_history: [{
type: 'accepted'
}],
+ status: 'accepted',
parent_id: '',
author_id: '123',
id: '2'
@@ -37,6 +38,7 @@ describe('models.Comment', () => {
status_history: [{
type: 'rejected'
}],
+ status: 'rejected',
parent_id: '',
author_id: '456',
id: '4'
@@ -46,6 +48,7 @@ describe('models.Comment', () => {
status_history: [{
type: 'premod'
}],
+ status: 'premod',
parent_id: '',
author_id: '456',
id: '5'
@@ -55,6 +58,7 @@ describe('models.Comment', () => {
status_history: [{
type: 'premod'
}],
+ status: 'premod',
parent_id: '',
author_id: '456',
id: '6'
@@ -184,20 +188,12 @@ describe('models.Comment', () => {
describe('#moderationQueue()', () => {
it('should find an array of new comments to moderate when pre-moderation', () => {
- return Comment.moderationQueue('pre').then((result) => {
+ return Comment.moderationQueue('premod').then((result) => {
expect(result).to.not.be.null;
expect(result).to.have.lengthOf(2);
});
});
- it('should find an array of new comments to moderate when post-moderation', () => {
- return Comment.moderationQueue('post').then((result) => {
- expect(result).to.not.be.null;
- expect(result).to.have.lengthOf(1);
- expect(result[0]).to.have.property('body', 'comment 30');
- });
- });
-
});
describe('#removeAction', () => {
@@ -227,6 +223,7 @@ describe('models.Comment', () => {
.then(() => Comment.findById(comment_id))
.then((c) => {
expect(c).to.have.property('status');
+ expect(c.status).to.equal('rejected');
expect(c.status_history).to.have.length(1);
expect(c.status_history[0]).to.have.property('type', 'rejected');
expect(c.status_history[0]).to.have.property('assigned_by', '123');
@@ -238,6 +235,8 @@ describe('models.Comment', () => {
.then(() => Comment.findById(comments[1].id))
.then((c) => {
expect(c).to.have.property('status_history');
+ expect(c).to.have.property('status');
+ expect(c.status).to.equal('rejected');
expect(c.status_history).to.have.length(2);
expect(c.status_history[0]).to.have.property('type', 'accepted');
expect(c.status_history[0]).to.have.property('assigned_by', null);
diff --git a/tests/routes/api/comments/index.js b/tests/routes/api/comments/index.js
index 360daa5dc..65b52e246 100644
--- a/tests/routes/api/comments/index.js
+++ b/tests/routes/api/comments/index.js
@@ -34,12 +34,14 @@ describe('/api/v1/comments', () => {
body: 'comment 20',
asset_id: 'asset',
author_id: '456',
+ status: 'rejected',
status_history: [{
type: 'rejected'
}]
}, {
body: 'comment 30',
asset_id: '456',
+ status: 'accepted',
status_history: [{
type: 'accepted'
}]
diff --git a/tests/routes/api/queue/index.js b/tests/routes/api/queue/index.js
index 378899967..6a7507618 100644
--- a/tests/routes/api/queue/index.js
+++ b/tests/routes/api/queue/index.js
@@ -21,6 +21,7 @@ describe('/api/v1/queue', () => {
body: 'comment 10',
asset_id: 'asset',
author_id: '123',
+ status: 'rejected',
status_history: [{
type: 'rejected'
}]
@@ -29,6 +30,7 @@ describe('/api/v1/queue', () => {
body: 'comment 20',
asset_id: 'asset',
author_id: '456',
+ status: 'premod',
status_history: [{
type: 'premod'
}]
@@ -36,6 +38,7 @@ describe('/api/v1/queue', () => {
id: 'hij',
body: 'comment 30',
asset_id: '456',
+ status: 'accepted',
status_history: [{
type: 'accepted'
}]
@@ -89,6 +92,7 @@ describe('/api/v1/queue', () => {
.set(passport.inject({roles: ['admin']}))
.then((res) => {
expect(res).to.have.status(200);
+ expect(res.body.comments).to.have.length(1);
expect(res.body.comments[0]).to.have.property('body');
expect(res.body.users[0]).to.have.property('displayName');
expect(res.body.actions[0]).to.have.property('action_type');
diff --git a/tests/routes/api/stream/index.js b/tests/routes/api/stream/index.js
index 5d192e976..d9b59d6fe 100644
--- a/tests/routes/api/stream/index.js
+++ b/tests/routes/api/stream/index.js
@@ -29,6 +29,7 @@ describe('/api/v1/stream', () => {
body: 'comment 10',
author_id: '',
parent_id: '',
+ status: 'accepted',
status_history: [{
type: 'accepted'
}]
@@ -37,6 +38,7 @@ describe('/api/v1/stream', () => {
body: 'comment 20',
author_id: '',
parent_id: '',
+ status: null,
status_history: []
}, {
id: 'uio',
@@ -44,6 +46,7 @@ describe('/api/v1/stream', () => {
asset_id: 'asset',
author_id: '456',
parent_id: '',
+ status: 'accepted',
status_history: [{
type: 'accepted'
}]
@@ -51,6 +54,7 @@ describe('/api/v1/stream', () => {
id: 'hij',
body: 'comment 40',
asset_id: '456',
+ status: 'rejected',
status_history: [{
type: 'rejected'
}]