fix: Event activity endpoint with deleted actor

closes #1061
This commit is contained in:
Tom Moor
2019-10-12 13:03:50 -07:00
parent e33aaec469
commit 2d913e3766
2 changed files with 25 additions and 0 deletions

View File

@ -44,6 +44,7 @@ router.post('events.list', auth(), pagination(), async ctx => {
{
model: User,
as: 'actor',
paranoid: false,
},
],
offset: ctx.state.pagination.offset,

View File

@ -39,6 +39,30 @@ describe('#events.list', async () => {
expect(body.data[0].id).toEqual(event.id);
});
it('should return events with deleted actors', async () => {
const { user, admin, document, collection } = await seed();
// event viewable in activity stream
const event = await buildEvent({
name: 'documents.publish',
collectionId: collection.id,
documentId: document.id,
teamId: user.teamId,
actorId: user.id,
});
await user.destroy();
const res = await server.post('/api/events.list', {
body: { token: admin.getJwtToken() },
});
const body = await res.json();
expect(res.status).toEqual(200);
expect(body.data.length).toEqual(1);
expect(body.data[0].id).toEqual(event.id);
});
it('should require authentication', async () => {
const res = await server.post('/api/events.list');
const body = await res.json();