From ce19cf80bf72940ffba91433c83b802a84b52c9a Mon Sep 17 00:00:00 2001 From: Naz Date: Tue, 26 Apr 2022 19:44:22 +0800 Subject: [PATCH] Added better coverage for author reassignment refs https://github.com/TryGhost/Toolbox/issues/268 - The test didn't check if the posts were successfully reasigned, so have added that part of logic --- test/regression/models/model_posts.test.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/test/regression/models/model_posts.test.js b/test/regression/models/model_posts.test.js index 22f404d34f..e9ad169fb0 100644 --- a/test/regression/models/model_posts.test.js +++ b/test/regression/models/model_posts.test.js @@ -1669,17 +1669,34 @@ describe('Post Model', function () { it('can reassign multiple posts by author', async function () { // We're going to delete all posts by user 1 - const authorData = {id: testUtils.DataGenerator.Content.users[0].id}; + const authorData = {id: testUtils.DataGenerator.Content.users[1].id}; + const ownerData = { + id: testUtils.DataGenerator.Content.users[0].id, + slug: testUtils.DataGenerator.Content.users[0].slug + }; const preReassignPosts = await models.Post.findAll({context: {internal: true}}); // There are 10 posts created by posts:mu fixture preReassignPosts.length.should.equal(10); + const preReassignOwnerWithPosts = await models.Post.findAll({ + filter: `authors:${ownerData.slug}`, + context: {internal: true} + }); + preReassignOwnerWithPosts.length.should.equal(2); + await models.Post.reassignByAuthor(authorData); const postReassignPosts = await models.Post.findAll({context: {internal: true}}); // All 10 should remain postReassignPosts.length.should.equal(10); + + const postReassignOwnerWithPosts = await models.Post.findAll({ + filter: `authors:${ownerData.slug}`, + context: {internal: true} + }); + // 2 own and 2 reassigned from the other author + postReassignOwnerWithPosts.length.should.equal(4); }); });