Merge branch 'master' into cookie-updates

This commit is contained in:
Wyatt Johnson
2017-08-10 23:24:03 +10:00
committed by GitHub
2 changed files with 42 additions and 4 deletions
+2 -2
View File
@@ -205,8 +205,8 @@ class TagsService {
return updateModel(item_type, query, {
$pull: {
tags: {
name: link.tag.name
}
'tag.name': link.tag.name,
},
}
});
}
+40 -2
View File
@@ -27,7 +27,7 @@ describe('services.TagsService', () => {
const id = comment.id;
const name = 'BEST';
const assigned_by = user.id;
await TagsService.add(id, 'COMMENTS', {
tag: {
name
@@ -45,7 +45,7 @@ describe('services.TagsService', () => {
const id = comment.id;
const name = 'BEST';
const assigned_by = user.id;
await TagsService.add(id, 'COMMENTS', {
tag: {
name
@@ -103,5 +103,43 @@ describe('services.TagsService', () => {
expect(tags.length).to.equal(0);
}
});
it('removes a tag out of 2', async () => {
const id = comment.id;
const name = 'BEST';
const assigned_by = user.id;
await TagsService.add(id, 'COMMENTS', {
tag: {
name: 'ANOTHER'
},
assigned_by
});
await TagsService.add(id, 'COMMENTS', {
tag: {
name
},
assigned_by
});
{
const {tags} = await CommentsService.findById(id);
expect(tags.length).to.equal(2);
}
// ok now to remove it
await TagsService.remove(id, 'COMMENTS', {
tag: {
name
},
assigned_by
});
{
const {tags} = await CommentsService.findById(id);
expect(tags.length).to.equal(1);
expect(tags[0].tag.name).to.equal('ANOTHER');
}
});
});
});