v3 adapt v2: port leave, join and invite for groups controller

This commit is contained in:
Matteo Pagliazzi
2016-04-05 13:03:20 +02:00
parent 374d11b0e4
commit 08239345b5
5 changed files with 64 additions and 43 deletions
@@ -1,6 +1,5 @@
import {
generateGroup,
createAndPopulateGroup,
generateUser,
translate as t,
} from '../../../helpers/api-integration/v2';
@@ -4,7 +4,7 @@ import {
} from '../../../helpers/api-integration/v2';
import { each } from 'lodash';
xdescribe('POST /groups/:id/invite', () => {
describe('POST /groups/:id/invite', () => {
context('user is a member of the group', () => {
each({
'public guild': {type: 'guild', privacy: 'public'},
@@ -27,8 +27,8 @@ xdescribe('POST /groups/:id/invite', () => {
await inviter.post(`/groups/${group._id}/invite`, {
uuids: [invitee._id],
});
await group.sync();
expect(group.invites).to.include(invitee._id);
group = await inviter.get(`/groups/${group._id}`);
expect(_.find(group.invites, {_id: invitee._id})._id).to.exists;
});
});
});
@@ -53,8 +53,8 @@ xdescribe('POST /groups/:id/invite', () => {
await inviter.post(`/groups/${group._id}/invite`, {
uuids: [invitee._id],
});
await group.sync();
expect(group.invites).to.include(invitee._id);
group = await inviter.get(`/groups/${group._id}`);
expect(_.find(group.invites, {_id: invitee._id})._id).to.exists;
});
});
});
@@ -5,7 +5,7 @@ import {
} from '../../../helpers/api-integration/v2';
import { each } from 'lodash';
xdescribe('POST /groups/:id/join', () => {
describe('POST /groups/:id/join', () => {
context('user is already a member of the group', () => {
it('returns an error');
});
@@ -30,9 +30,8 @@ xdescribe('POST /groups/:id/join', () => {
it(`allows user to join a ${groupType}`, async () => {
await invitee.post(`/groups/${group._id}/join`);
await group.sync();
expect(group.members).to.include(invitee._id);
group = await invitee.get(`/groups/${group._id}`);
expect(_.find(group.members, {_id: invitee._id})._id).to.exists;
});
});
});
@@ -78,9 +77,9 @@ xdescribe('POST /groups/:id/join', () => {
it('allows user to join a public guild', async () => {
await user.post(`/groups/${group._id}/join`);
await group.sync();
group = await user.get(`/groups/${group._id}`);
expect(group.members).to.include(user._id);
expect(_.find(group.members, {_id: user._id})._id).to.exists;
});
});
@@ -103,9 +102,9 @@ xdescribe('POST /groups/:id/join', () => {
it('makes the joining user the leader', async () => {
await user.post(`/groups/${group._id}/join`);
await group.sync();
group = await user.get(`/groups/${group._id}`);
await expect(group.leader).to.eql(user._id);
await expect(group.leader._id).to.eql(user._id);
});
});
});
@@ -3,7 +3,7 @@ import {
createAndPopulateGroup,
} from '../../../helpers/api-integration/v2';
xdescribe('POST /groups/:id/leave', () => {
describe('POST /groups/:id/leave', () => {
context('user is not member of the group', () => {
it('returns an error');
});
@@ -28,9 +28,9 @@ xdescribe('POST /groups/:id/leave', () => {
it('leaves the group', async () => {
await user.post(`/groups/${group._id}/leave`);
await group.sync();
await user.sync();
expect(group.members).to.not.include(user._id);
expect(user.guilds).to.not.include(group._id);
});
});