Adding tests to prove expected behavior around force starting a quest (#7848)

* starting

* adding tests to prove the expected behavior occurs around force starting a quest. part of #7653

* fixing up tests and adding functionality to remove user from quest if they are not in the questing party

* adding code to handle when the user is deleted and added a test around that situation

* fixing up comments
This commit is contained in:
Travis
2016-09-10 21:10:37 -07:00
committed by Blade Barringer
parent ed4039c08c
commit b73cf2e272
2 changed files with 93 additions and 0 deletions

View File

@@ -393,6 +393,17 @@ schema.methods.startQuest = async function startQuest (user) {
let nonUserQuestMembers = _.keys(this.quest.members);
removeFromArray(nonUserQuestMembers, user._id);
// remove any users from quest.members who aren't in the party
let partyId = this._id;
let questMembers = this.quest.members;
await Bluebird.map(Object.keys(this.quest.members), async (memberId) => {
let member = await User.findOne({_id: memberId, 'party._id': partyId}).select('_id').lean();
if (!member) {
delete questMembers[memberId];
}
});
if (userIsParticipating) {
user.party.quest.key = this.quest.key;
user.party.quest.progress.down = 0;