Skip to content

Commit

Permalink
fix(incident): fix assignee on incident timeline
Browse files Browse the repository at this point in the history
  • Loading branch information
intyro authored and charitymarani committed Aug 23, 2019
1 parent c799317 commit 6843398
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/server/helpers/incidentHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ const updateAssignedOrCcdUser = async (
},
});

await handleCCUpdateNotification(req, ccdUser, incident.id, '');
if (ccdUser && ccdUser.length > 0) {
await handleCCUpdateNotification(req, ccdUser, incident.id, '');
}

return selectedUser.action({ ...selectedUser.arguments, incident, res });
};
Expand All @@ -210,7 +212,6 @@ const updateIncident = async (incident, req, res) => {
categoryId: req.body.categoryId || incident.categoryId,
levelId: req.body.levelId || incident.levelId,
});

return res.status(200).send({ data: incident, status: 'success' });
};

Expand Down
26 changes: 18 additions & 8 deletions src/tests/incidents.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,36 @@ describe('Incident Tests', () => {
});
});
});

it('should update an incident provided an existing incident ID', done => {
it('should update an incident when someone gets assigned to the incident', done => {
sendRequest('post', incidentsEndpoint, testIncident, (err, res) => {
const updateIncidentUrl = '/api/incidents/' + res.body.data.id;
const { id } = res.body.data;
const updateIncidentUrl = '/api/incidents/' + id;
sendRequest(
'put',
updateIncidentUrl,
{ ...testIncident, statusId: 3 },
{
...testIncident,
ccd: [
{
userId: 'cjl6fecrb11115vf09xly2f65',
incidentId: id,
},
],
assignee: {
userId: 'cjl6egyei00005dnytqp4a06l',
incidentId: id,
},
},
(error, response) => {
expect(response.body.data.statusId).toEqual(3);
expect(response.body.status).toEqual('success');
done();
}
);
});
});

it('should update an incident when someone gets assigned to it', done => {
it('should update an incident when someone gets ccd to it', done => {
makeServerCall(assigneeRequestBody, done, 'put');
});

it('should update an incident when someone gets ccd to it', done => {
makeServerCall(ccdRequestBody, done, 'put');
});
Expand Down

0 comments on commit 6843398

Please sign in to comment.