Skip to content

Commit 6d31b55

Browse files
remove feature flag (#1703)
1 parent 75f563c commit 6d31b55

File tree

2 files changed

+8
-74
lines changed

2 files changed

+8
-74
lines changed

controllers/tasks.js

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ const updateTaskStatus = async (req, res, next) => {
312312
try {
313313
let userStatusUpdate;
314314
const taskId = req.params.id;
315-
const { userStatusFlag } = req.query;
316315
const { id: userId, username } = req.userData;
317316
const task = await tasks.fetchSelfTask(taskId, userId);
318317

@@ -321,34 +320,18 @@ const updateTaskStatus = async (req, res, next) => {
321320
if (task.taskData.status === TASK_STATUS.VERIFIED || req.body.status === TASK_STATUS.MERGED)
322321
return res.boom.forbidden("Status cannot be updated. Please contact admin.");
323322

324-
if (userStatusFlag) {
325-
if (task.taskData.status === TASK_STATUS.DONE && req.body.percentCompleted < 100) {
326-
if (req.body.status === TASK_STATUS.DONE || !req.body.status) {
327-
return res.boom.badRequest("Task percentCompleted can't updated as status is DONE");
328-
}
329-
}
330-
331-
if (
332-
(req.body.status === TASK_STATUS.DONE || req.body.status === TASK_STATUS.VERIFIED) &&
333-
task.taskData.percentCompleted !== 100
334-
) {
335-
if (req.body.percentCompleted !== 100) {
336-
return res.boom.badRequest("Status cannot be updated. Task is not done yet");
337-
}
323+
if (task.taskData.status === TASK_STATUS.DONE && req.body.percentCompleted < 100) {
324+
if (req.body.status === TASK_STATUS.DONE || !req.body.status) {
325+
return res.boom.badRequest("Task percentCompleted can't updated as status is DONE");
338326
}
339327
}
340328

341-
if (task.taskData.status === TASK_STATUS.COMPLETED && req.body.percentCompleted < 100) {
342-
if (req.body.status === TASK_STATUS.COMPLETED || !req.body.status) {
343-
return res.boom.badRequest("Task percentCompleted can't updated as status is COMPLETED");
344-
}
345-
}
346329
if (
347-
(req.body.status === TASK_STATUS.COMPLETED || req.body.status === TASK_STATUS.VERIFIED) &&
330+
(req.body.status === TASK_STATUS.DONE || req.body.status === TASK_STATUS.VERIFIED) &&
348331
task.taskData.percentCompleted !== 100
349332
) {
350333
if (req.body.percentCompleted !== 100) {
351-
return res.boom.badRequest("Status cannot be updated. Task is not completed yet");
334+
return res.boom.badRequest("Status cannot be updated. Task is not done yet");
352335
}
353336
}
354337

test/integration/tasks.test.js

Lines changed: 3 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -959,19 +959,7 @@ describe("Tasks", function () {
959959
expect(res.body.message).to.be.equal("Status cannot be updated. Please contact admin.");
960960
});
961961

962-
it("Should give 400 if percentCompleted is not 100 and new status is COMPLETED ", async function () {
963-
taskId = (await tasks.updateTask({ ...taskData, status: "REVIEW", assignee: appOwner.username })).taskId;
964-
const res = await chai
965-
.request(app)
966-
.patch(`/tasks/self/${taskId}`)
967-
.set("cookie", `${cookieName}=${jwt}`)
968-
.send({ ...taskStatusData, status: "COMPLETED" });
969-
970-
expect(res).to.have.status(400);
971-
expect(res.body.message).to.be.equal("Status cannot be updated. Task is not completed yet");
972-
});
973-
974-
it("Should give 400 if percentCompleted is not 100 and new status is DONE under feature flag ", async function () {
962+
it("Should give 400 if percentCompleted is not 100 and new status is DONE", async function () {
975963
taskId = (await tasks.updateTask({ ...taskData, status: "REVIEW", assignee: appOwner.username })).taskId;
976964
const res = await chai
977965
.request(app)
@@ -983,19 +971,7 @@ describe("Tasks", function () {
983971
expect(res.body.message).to.be.equal("Status cannot be updated. Task is not done yet");
984972
});
985973

986-
it("Should give 400 if percentCompleted is not 100 and new status is VERIFIED ", async function () {
987-
taskId = (await tasks.updateTask({ ...taskData, status: "REVIEW", assignee: appOwner.username })).taskId;
988-
const res = await chai
989-
.request(app)
990-
.patch(`/tasks/self/${taskId}`)
991-
.set("cookie", `${cookieName}=${jwt}`)
992-
.send({ ...taskStatusData, status: "VERIFIED" });
993-
994-
expect(res).to.have.status(400);
995-
expect(res.body.message).to.be.equal("Status cannot be updated. Task is not completed yet");
996-
});
997-
998-
it("Should give 400 if percentCompleted is not 100 and new status is VERIFIED under feature flag", async function () {
974+
it("Should give 400 if percentCompleted is not 100 and new status is VERIFIED", async function () {
999975
taskId = (await tasks.updateTask({ ...taskData, status: "REVIEW", assignee: appOwner.username })).taskId;
1000976
const res = await chai
1001977
.request(app)
@@ -1007,32 +983,7 @@ describe("Tasks", function () {
1007983
expect(res.body.message).to.be.equal("Status cannot be updated. Task is not done yet");
1008984
});
1009985

1010-
it("Should give 400 if status is COMPLETED and newpercent is less than 100", async function () {
1011-
const taskData = {
1012-
title: "Test task",
1013-
type: "feature",
1014-
endsOn: 1234,
1015-
startedOn: 4567,
1016-
status: "completed",
1017-
percentCompleted: 100,
1018-
participants: [],
1019-
assignee: appOwner.username,
1020-
completionAward: { [DINERO]: 3, [NEELAM]: 300 },
1021-
lossRate: { [DINERO]: 1 },
1022-
isNoteworthy: true,
1023-
};
1024-
taskId = (await tasks.updateTask(taskData)).taskId;
1025-
const res = await chai
1026-
.request(app)
1027-
.patch(`/tasks/self/${taskId}`)
1028-
.set("cookie", `${cookieName}=${jwt}`)
1029-
.send({ percentCompleted: 80 });
1030-
1031-
expect(res).to.have.status(400);
1032-
expect(res.body.message).to.be.equal("Task percentCompleted can't updated as status is COMPLETED");
1033-
});
1034-
1035-
it("Should give 400 if status is DONE and newpercent is less than 100 under feature flag", async function () {
986+
it("Should give 400 if status is DONE and newpercent is less than 100", async function () {
1036987
taskId = (await tasks.updateTask(updateTaskStatus[0])).taskId;
1037988
const res = await chai
1038989
.request(app)

0 commit comments

Comments
 (0)