From 5c80de0bb8a180b62ac22b722bc9bcec4a01f6ed Mon Sep 17 00:00:00 2001 From: Pankaj Date: Thu, 9 Jan 2025 22:58:19 +0530 Subject: [PATCH] fix: Changed status code to 409 for sending Conflict response (#2339) --- controllers/onboardingExtension.ts | 2 +- test/integration/onboardingExtension.test.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/controllers/onboardingExtension.ts b/controllers/onboardingExtension.ts index bec135274..c03b45df6 100644 --- a/controllers/onboardingExtension.ts +++ b/controllers/onboardingExtension.ts @@ -57,7 +57,7 @@ export const createOnboardingExtensionRequestController = async (req: Onboarding }); if(latestExtensionRequest && latestExtensionRequest.state === REQUEST_STATE.PENDING){ - return res.boom.badRequest(REQUEST_ALREADY_PENDING); + return res.boom.conflict(REQUEST_ALREADY_PENDING); } const millisecondsInThirtyOneDays = convertDaysToMilliseconds(31); diff --git a/test/integration/onboardingExtension.test.ts b/test/integration/onboardingExtension.test.ts index 454cc9688..703edeaca 100644 --- a/test/integration/onboardingExtension.test.ts +++ b/test/integration/onboardingExtension.test.ts @@ -215,7 +215,7 @@ describe("/requests Onboarding Extension", () => { }) }) - it("should return 400 response when a user already has a pending request", (done)=> { + it("should return 409 response when a user already has a pending request", (done)=> { createUserStatusWithState(testUserId, userStatusModel, userState.ONBOARDING); requestsQuery.createRequest({...extensionRequest, state: REQUEST_STATE.PENDING, userId: testUserId}); @@ -225,8 +225,8 @@ describe("/requests Onboarding Extension", () => { .send(body) .end((err, res) => { if (err) return done(err); - expect(res.statusCode).to.equal(400); - expect(res.body.error).to.equal("Bad Request"); + expect(res.statusCode).to.equal(409); + expect(res.body.error).to.equal("Conflict"); expect(res.body.message).to.equal(REQUEST_ALREADY_PENDING); done(); })