Fixes: Can't reshre a link once revoked

closes #733
This commit is contained in:
Tom Moor
2018-08-02 22:17:41 -07:00
parent 8acb60f4c7
commit cdd1fc4fb7
2 changed files with 19 additions and 0 deletions

View File

@ -64,6 +64,7 @@ router.post('shares.create', auth(), async ctx => {
documentId,
userId: user.id,
teamId: user.teamId,
revokedAt: null,
},
});

View File

@ -88,6 +88,24 @@ describe('#shares.create', async () => {
expect(body.data.documentTitle).toBe(document.title);
});
it('should allow creating a share record if link previously revoked', async () => {
const { user, document } = await seed();
const share = await buildShare({
documentId: document.id,
teamId: user.teamId,
userId: user.id,
});
await share.revoke();
const res = await server.post('/api/shares.create', {
body: { token: user.getJwtToken(), documentId: document.id },
});
const body = await res.json();
expect(res.status).toEqual(200);
expect(body.data.id).not.toEqual(share.id);
expect(body.data.documentTitle).toBe(document.title);
});
it('should return existing share link for document and user', async () => {
const { user, document } = await seed();
const share = await buildShare({