Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit b9e2b89

Browse files
committed
Move create membership to upsert
1 parent 5e599b0 commit b9e2b89

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

clubs/handlers/createMember.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = [
1717
const { userId, userType } = req.body;
1818
const { id: dojoId } = req.params;
1919
try {
20-
return res.send(await memberController.create(userId, dojoId, userType));
20+
return res.send(await memberController.upsert(userId, dojoId, userType));
2121
} catch (e) {
2222
next(e);
2323
}

clubs/routes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ const handlers = require('./handlers');
44

55
const clubRouter = express.Router();
66
clubRouter.get('/:id', validations.load, handlers.load);
7-
clubRouter.post('/:id/members', validations.members.create, handlers.members.upsert);
7+
clubRouter.post('/:id/members', validations.members.create, handlers.members.create);
88
module.exports = clubRouter;

test/unit/clubs/handlers/createMember.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('clubs/handlers:createMember', () => {
1313

1414
before(() => {
1515
sandbox = sinon.createSandbox();
16-
membershipsController.create = sandbox.stub();
16+
membershipsController.upsert = sandbox.stub();
1717
clubsController.load = sandbox.stub();
1818
handlers = proxy('../../../../clubs/handlers/createMember', {
1919
'../../memberships/controller': membershipsController,
@@ -61,17 +61,17 @@ describe('clubs/handlers:createMember', () => {
6161
expect(next).to.have.been.calledWith(err);
6262
});
6363

64-
it('should create the membership', async () => {
64+
it('should upsert the membership', async () => {
6565
req.body = {
6666
userId: 'u1',
6767
userType: 'champion',
6868
};
6969
req.params = {
7070
id: 'd1',
7171
};
72-
membershipsController.create.resolves({ id: 'm1' });
72+
membershipsController.upsert.resolves({ id: 'm1' });
7373
await handlers[1](req, res, next);
74-
expect(membershipsController.create).to.have.been.calledOnce.and
74+
expect(membershipsController.upsert).to.have.been.calledOnce.and
7575
.calledWith('u1', 'd1', 'champion');
7676
expect(res.send).to.have.been.calledWith({ id: 'm1' });
7777
});

0 commit comments

Comments
 (0)