Skip to content

Commit

Permalink
Merge pull request #1691 from onaio/1690-fix-revoke-assignment-bug
Browse files Browse the repository at this point in the history
Fix revoke assignments bug
  • Loading branch information
ciremusyoka committed Mar 15, 2022
2 parents 31e9625 + 4c4413d commit e0166d1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const getPayload = (
}

// turns out if you put it in the loop it keeps subtracting a day for every iteration
const retireDate = now.format();
const retireDate = moment(new Date()).format();

for (const retiredOrgId of initialOrgs.filter(orgId => !selectedOrgs.includes(orgId))) {
if (!payload.map(obj => obj.organization).includes(retiredOrgId)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,34 @@ describe('PlanAssignment/helpers', () => {
const payload = getPayload(selectedOrgs, plan, raZambiaNode);
expect(payload).toEqual(customYearAssignments);
});

it('Retires plans correctly - toDate dates should be set to current date', () => {
const envModule = require('../../../../../../configs/env');
envModule.PLAN_TEAM_ASSIGNMENT_EXPIRY_YEARS = 5;

if (!raZambiaNode) {
fail();
}

const plan = plans[0];
const selectedOrgs = ['2'];
const initialOrgs = ['1', '2', '3'];

const payload = getPayload(selectedOrgs, plan, raZambiaNode, initialOrgs);
// current date set to 30/12/2019
expect(payload).toEqual([
{
...customYearAssignments[1],
toDate: '2024-12-30T00:00:00+00:00',
},
{
...customYearAssignments[0],
toDate: '2019-12-30T00:00:00+00:00',
},
{
...customYearAssignments[2],
toDate: '2019-12-30T00:00:00+00:00',
},
]);
});
});

0 comments on commit e0166d1

Please sign in to comment.