Skip to content

Commit

Permalink
Merge 8b35f41 into 66fe6aa
Browse files Browse the repository at this point in the history
  • Loading branch information
joeeasy committed Nov 6, 2018
2 parents 66fe6aa + 8b35f41 commit 922c9ae
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
25 changes: 18 additions & 7 deletions server/controllers/userController.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,13 +375,24 @@ const userController = {
Users.update(updates, {
where: {
id
},
returning: true,
plain: true
}).then(user => res.status(200).jsend.success({
message: 'Your profile has been updated successfully',
user
}));
}
}).then(() => {
Users.findById(id, {
include: [
{ model: Articles, as: 'articles' },
{ model: Ratings, as: 'ratings' },
{ model: Bookmarks, as: 'bookmarks' },
'followed',
'follower'
]
}).then((user) => {
delete user.password;
return res.status(200).jsend.success({
message: 'Your profile has been updated successfully',
user
});
});
});
};
if (req.file) {
const file = dataUri(req);
Expand Down
12 changes: 6 additions & 6 deletions test/users.test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ describe('Update User Endpoint /api/v1/users/update', () => {
.end((err, res) => {
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body.data.user[1].firstname).to.equal('joe');
expect(res.body.data.user[1].lastname).to.equal('easy');
expect(res.body.data.user[1].bio).to.equal('Hello, here is a brief information about me');
expect(res.body.data.user.firstname).to.equal('joe');
expect(res.body.data.user.lastname).to.equal('easy');
expect(res.body.data.user.bio).to.equal('Hello, here is a brief information about me');
expect(res.body.data.message).to.equal('Your profile has been updated successfully');
done();
});
Expand All @@ -117,9 +117,9 @@ describe('Update User Endpoint /api/v1/users/update', () => {
.type('form')
.end((err, res) => {
expect(res).to.have.status(200);
expect(res.body.data.user[1].firstname).to.equal('jehonadab');
expect(res.body.data.user[1].lastname).to.equal('hehehehehe');
expect(res.body.data.user[1].bio).to.equal('Here is a brief information about me');
expect(res.body.data.user.firstname).to.equal('jehonadab');
expect(res.body.data.user.lastname).to.equal('hehehehehe');
expect(res.body.data.user.bio).to.equal('Here is a brief information about me');
expect(res.body.data.message).to.equal('Your profile has been updated successfully');
done();
});
Expand Down

0 comments on commit 922c9ae

Please sign in to comment.