Prevent submission of blank invitation, fixes #7807 (#8080)

This commit is contained in:
Julie Torres
2016-09-30 12:25:57 -04:00
committed by Blade Barringer
parent 17b0329c43
commit 9b10f348cc
3 changed files with 43 additions and 14 deletions

View File

@@ -57,11 +57,28 @@ describe('Post /groups/:groupId/invite', () => {
});
});
it('returns empty when uuids is empty', async () => {
it('returns an error when uuids and emails are empty', async () => {
await expect(inviter.post(`/groups/${group._id}/invite`, {
emails: [],
uuids: [],
}))
.to.eventually.be.empty;
.to.eventually.be.rejected.and.eql({
code: 400,
error: 'BadRequest',
message: t('inviteMustNotBeEmpty'),
});
});
it('returns an error when uuids is empty and emails is undefined', async () => {
await expect(inviter.post(`/groups/${group._id}/invite`, {
emails: undefined,
uuids: [],
}))
.to.eventually.be.rejected.and.eql({
code: 400,
error: 'BadRequest',
message: t('inviteMissingUuid'),
});
});
it('returns an error when there are more than INVITES_LIMIT uuids', async () => {
@@ -159,11 +176,16 @@ describe('Post /groups/:groupId/invite', () => {
});
});
it('returns empty when emails is an empty array', async () => {
it('returns an error when emails is empty and uuids is undefined', async () => {
await expect(inviter.post(`/groups/${group._id}/invite`, {
emails: [],
uuids: undefined,
}))
.to.eventually.be.empty;
.to.eventually.be.rejected.and.eql({
code: 400,
error: 'BadRequest',
message: t('inviteMissingEmail'),
});
});
it('returns an error when there are more than INVITES_LIMIT emails', async () => {