mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
Ensured tavern is not returned twice and removed leader population
This commit is contained in:
@@ -76,8 +76,7 @@ describe('GET /groups', () => {
|
||||
it('returns only the user\'s party when party passed in as query', async () => {
|
||||
await expect(user.get('/groups?type=party'))
|
||||
.to.eventually.have.a.lengthOf(1)
|
||||
.and.to.have.deep.property('[0]')
|
||||
.and.to.have.property('leader._id', user._id);
|
||||
.and.to.have.deep.property('[0]');
|
||||
});
|
||||
|
||||
it('returns all public guilds when publicGuilds passed in as query', async () => {
|
||||
@@ -91,9 +90,7 @@ describe('GET /groups', () => {
|
||||
});
|
||||
|
||||
it('returns a list of groups user has access to', async () => {
|
||||
let groups = await user.get('/groups?type=privateGuilds,publicGuilds,party');
|
||||
|
||||
expect(groups.length)
|
||||
.to.eql(NUMBER_OF_GROUPS_USER_CAN_VIEW);
|
||||
await expect(user.get('/groups?type=privateGuilds,publicGuilds,party,tavern'))
|
||||
.to.eventually.have.lengthOf(NUMBER_OF_GROUPS_USER_CAN_VIEW);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -86,14 +86,14 @@ api.getGroups = {
|
||||
|
||||
// TODO validate types are acceptable? probably not necessary
|
||||
let types = req.query.type.split(',');
|
||||
let groupFields = 'name description memberCount balance leader';
|
||||
let groupFields = 'name description memberCount balance';
|
||||
let sort = '-memberCount';
|
||||
let queries = [];
|
||||
|
||||
types.forEach(type => {
|
||||
switch (type) {
|
||||
case 'party':
|
||||
queries.push(Group.getGroup({user, groupId: 'party', fields: groupFields, populateLeader: true}));
|
||||
queries.push(Group.getGroup({user, groupId: 'party', fields: groupFields}));
|
||||
break;
|
||||
case 'privateGuilds':
|
||||
queries.push(Group.find({
|
||||
@@ -109,7 +109,9 @@ api.getGroups = {
|
||||
}).select(groupFields).sort(sort).exec()); // TODO use lean?
|
||||
break;
|
||||
case 'tavern':
|
||||
queries.push(Group.getGroup({user, groupId: 'habitrpg', fields: groupFields, populateLeader: true}));
|
||||
if (types.indexOf('publicGuilds') === -1) {
|
||||
queries.push(Group.getGroup({user, groupId: 'habitrpg', fields: groupFields}));
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user