Clear invites from user when the request fails because the invite is invalid (#7852)

* making requests to accept or reject a request fail because the invite is invalid clear the invite from the user so it doesn't require admin intervention. part of #7653

* Adding await
This commit is contained in:
Travis
2016-08-05 10:34:06 -07:00
committed by Blade Barringer
parent 093c5a72df
commit d7c5d05f13
3 changed files with 39 additions and 12 deletions

View File

@@ -74,6 +74,21 @@ describe('POST /groups/:groupId/quests/accept', () => {
});
});
it('clears the invalid invite from the user when the request fails', async () => {
await leader.post(`/groups/${questingGroup._id}/quests/invite/${PET_QUEST}`);
await partyMembers[0].post(`/groups/${questingGroup._id}/quests/accept`);
await expect(partyMembers[0].post(`/groups/${questingGroup._id}/quests/accept`))
.to.eventually.be.rejected.and.eql({
code: 400,
error: 'BadRequest',
message: t('questAlreadyAccepted'),
});
await partyMembers[0].sync();
expect(partyMembers[0].party.quest.RSVPNeeded).to.be.false;
});
it('does not accept invite for a quest already underway', async () => {
await leader.post(`/groups/${questingGroup._id}/quests/invite/${PET_QUEST}`);
await partyMembers[0].post(`/groups/${questingGroup._id}/quests/accept`);

View File

@@ -83,6 +83,21 @@ describe('POST /groups/:groupId/quests/reject', () => {
});
});
it('clears the user rsvp needed if the request fails because the request is invalid', async () => {
await leader.post(`/groups/${questingGroup._id}/quests/invite/${PET_QUEST}`);
await partyMembers[0].post(`/groups/${questingGroup._id}/quests/reject`);
await expect(partyMembers[0].post(`/groups/${questingGroup._id}/quests/reject`))
.to.eventually.be.rejected.and.eql({
code: 400,
error: 'BadRequest',
message: t('questAlreadyRejected'),
});
await partyMembers[0].sync();
expect(partyMembers[0].party.quest.RSVPNeeded).to.be.false;
});
it('return an error when a user rejects an invite already accepted', async () => {
await leader.post(`/groups/${questingGroup._id}/quests/invite/${PET_QUEST}`);
await partyMembers[0].post(`/groups/${questingGroup._id}/quests/accept`);