Skip to content

Commit

Permalink
fix: use name instead of displayName when updating developer
Browse files Browse the repository at this point in the history
  • Loading branch information
ijemmao committed May 5, 2024
1 parent 8d08544 commit 1407a0b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/controllers/developers/__tests__/developers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('developers', () => {
});

it('puts a developer', async () => {
const userData = { email: 'email', firebaseId: 'firebaseId', displayName: 'name' };
const userData = { email: 'email', firebaseId: 'firebaseId', name: 'name' };
const req = requestFixture({ body: userData });
const res = responseFixture();
const next = nextFunctionFixture();
Expand Down
7 changes: 1 addition & 6 deletions src/controllers/developers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,7 @@ export const putDeveloper: MiddleWare = async (req, res, next) => {

try {
return res.send(await putDeveloperHelper({ query: { _id: id }, data: req.body }));
} catch (err: any) {
// TODO: write test to make sure that when there's no developer, the postDeveloper method
// gets called
if (err.message === 'No developer to update') {
return postDeveloper(req, res, next);
}
} catch (err) {
return next(err);
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/middleware/validateUpdateDeveloperBody.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { MiddleWare } from '../types';
const developersJoiSchema = Joi.object().keys({
firebaseId: Joi.string().required(),
email: Joi.string().allow('', null).optional(),
displayName: Joi.string().allow('', null).optional(),
name: Joi.string().allow('', null).optional(),
});

const validateUpdateDeveloperBody: MiddleWare = (req, res, next) => {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/APIs/DevelopersAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const putDeveloper = async (user: Partial<User>) => {
data: {
firebaseId: user.uid,
email: user.email,
displayName: user.displayName,
name: user.displayName,
},
});

Expand Down

0 comments on commit 1407a0b

Please sign in to comment.