Skip to content

Commit

Permalink
fixing claim tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlebl committed Jul 29, 2024
1 parent 912b309 commit 50ace20
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions nomad-rest-api/controllers/claim.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,17 @@ export const approveClaims = async (req, res) => {
req.body.map(async id => {
const claim = await Claim.findById(id)
const instrument = await Instrument.findById(claim.instrument, 'cost')
const { grantId, multiplier } = await getGrantInfo(claim.user, claim.group)

claim.status = 'Approved'
claim.grantCosting = {
grantId,
cost: +claim.expTime * instrument.cost * multiplier

const grant = await getGrantInfo(claim.user, claim.group)
if (grant) {
const { grantId, multiplier } = grant

claim.grantCosting = {
grantId,
cost: +claim.expTime * instrument.cost * multiplier
}
}

await claim.save()
Expand Down
2 changes: 1 addition & 1 deletion nomad-rest-api/tests/claim.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ describe('PATCH /', () => {
})

describe('PUT /approve', () => {
it('should change status of testClaimRwo to "approve"', async () => {
it('should change status of testClaimTwo to "approve"', async () => {
const { body } = await request(app)
.put('/claims/approve')
.set('Authorization', `Bearer ${testUserAdmin.tokens[0].token}`)
Expand Down

0 comments on commit 50ace20

Please sign in to comment.