Skip to content
Snippets Groups Projects
Commit aa1e4df2 authored by Tania Fecheta's avatar Tania Fecheta
Browse files

Merge branch 'HIN-1118' into 'develop'

fix(fragmentsRecommendations): reviewers cannot write a review on an older version

See merge request !147
parents 76879082 75a0d2ac
No related branches found
No related tags found
3 merge requests!160Update staging with master features,!150Develop,!147fix(fragmentsRecommendations): reviewers cannot write a review on an older version
......@@ -78,6 +78,15 @@ module.exports = models => async (req, res) => {
.json({ error: 'Cannot make a recommendation on an older version.' })
}
if (
recommendationType === recommendations.type.review &&
last(collection.fragments) !== fragmentId
) {
return res
.status(400)
.json({ error: 'Cannot write a review on an older version.' })
}
if (
recommendation === recommendations.publish &&
recommendationType === recommendations.type.editor &&
......
......@@ -384,6 +384,29 @@ describe('Post fragments recommendations route handler', () => {
'Cannot make a recommendation on an older version.',
)
})
it('should return an error when a reviewer writes a review on an older version of a manuscript', async () => {
const { reviewer } = testFixtures.users
const { twoVersionsCollection } = testFixtures.collections
const { fragment } = testFixtures.fragments
body.recommendationType = 'review'
const res = await requests.sendRequest({
body,
userId: reviewer.id,
models,
route,
path,
params: {
collectionId: twoVersionsCollection.id,
fragmentId: fragment.id,
},
})
expect(res.statusCode).toBe(400)
const data = JSON.parse(res._getData())
expect(data.error).toEqual('Cannot write a review on an older version.')
})
it('should return an error when an EiC makes a decision on an older version of a manuscript', async () => {
const { editorInChief } = testFixtures.users
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment