mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-24 14:43:08 +03:00
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
This commit is contained in:
parent
f82ff87177
commit
ce19cf80bf
@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user