From 6c33d2abdfdd1eaf84906276b7b4736443868b86 Mon Sep 17 00:00:00 2001 From: Lakshay Manchanda <45519620+lakshayman@users.noreply.github.com> Date: Fri, 30 Aug 2024 00:49:23 +0530 Subject: [PATCH] Fixed users self patch API for new users (#2069) * Fixed users self patch API for new users * Tests fixed * Tests fixed --- controllers/users.js | 2 +- test/integration/users.test.js | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/controllers/users.js b/controllers/users.js index 858212fa4..82c197ced 100644 --- a/controllers/users.js +++ b/controllers/users.js @@ -410,7 +410,7 @@ const updateSelf = async (req, res) => { } } - if (userRoles.in_discord) { + if (userRoles.in_discord && !user.incompleteUserDetails) { const membersInDiscord = await getDiscordMembers(); const discordMember = membersInDiscord.find((member) => member.user.id === discordId); if (discordMember) { diff --git a/test/integration/users.test.js b/test/integration/users.test.js index 0e063fab0..5d8fd720c 100644 --- a/test/integration/users.test.js +++ b/test/integration/users.test.js @@ -2344,7 +2344,11 @@ describe("Users", function () { }); describe("PATCH /users/self for developers", function () { - beforeEach(function () { + let id, jwtoken; + + beforeEach(async function () { + id = await addUser(); + jwtoken = authService.generateAuthToken({ userId: id }); fetchStub = Sinon.stub(global, "fetch"); const discordMembers = [...getDiscordMembers]; discordMembers[0].user.id = "12345"; @@ -2365,7 +2369,7 @@ describe("Users", function () { chai .request(app) .patch("/users/self") - .set("cookie", `${cookieName}=${jwt}`) + .set("cookie", `${cookieName}=${jwtoken}`) .send({ first_name: "Test first_name", })