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

fix(fragmentRecommendation): allow HE to make another recommendation on the...

fix(fragmentRecommendation): allow HE to make another recommendation on the same version when EiC de
parent 9a0fa086
No related branches found
No related tags found
3 merge requests!176Sprint 24,!171Sprint 24,!157fix(fragmentRecommendation): allow HE to make another recommendation on the same…
...@@ -459,6 +459,48 @@ const fragments = { ...@@ -459,6 +459,48 @@ const fragments = {
updatedOn: chance.timestamp(), updatedOn: chance.timestamp(),
submittedOn: chance.timestamp(), submittedOn: chance.timestamp(),
}, },
{
recommendation: 'publish',
recommendationType: 'editorRecommendation',
comments: [
{
content: chance.paragraph(),
public: true,
files: [
{
id: chance.guid(),
name: 'file.pdf',
size: chance.natural(),
},
],
},
],
id: chance.guid(),
userId: handlingEditor.id,
createdOn: 1542361074012,
updatedOn: chance.timestamp(),
},
{
recommendation: 'return-to-handling-editor',
recommendationType: 'editorRecommendation',
comments: [
{
content: chance.paragraph(),
public: true,
files: [
{
id: chance.guid(),
name: 'file.pdf',
size: chance.natural(),
},
],
},
],
id: chance.guid(),
userId: handlingEditor.id,
createdOn: 1542361115749,
updatedOn: chance.timestamp(),
},
], ],
authors: [ authors: [
{ {
......
...@@ -45,6 +45,9 @@ module.exports = models => async (req, res) => { ...@@ -45,6 +45,9 @@ module.exports = models => async (req, res) => {
r => r.userId === req.user, r => r.userId === req.user,
) )
const returnToHERecommendations = get(fragment, 'recommendations', []).filter(
r => r.recommendation === 'return-to-handling-editor',
)
const authsome = authsomeHelper.getAuthsome(models) const authsome = authsomeHelper.getAuthsome(models)
const target = { const target = {
fragment, fragment,
...@@ -84,9 +87,15 @@ module.exports = models => async (req, res) => { ...@@ -84,9 +87,15 @@ module.exports = models => async (req, res) => {
.status(400) .status(400)
.json({ error: 'Cannot write another review on this version.' }) .json({ error: 'Cannot write another review on this version.' })
} }
return res if (
.status(400) recommendationType === recommendations.type.editor &&
.json({ error: 'Cannot make another recommendation on this version.' }) last(returnToHERecommendations).createdOn <
last(currentUserRecommendation).createdOn
) {
return res
.status(400)
.json({ error: 'Cannot make another recommendation on this version.' })
}
} }
if ( if (
......
...@@ -428,6 +428,27 @@ describe('Post fragments recommendations route handler', () => { ...@@ -428,6 +428,27 @@ describe('Post fragments recommendations route handler', () => {
expect(data.error).toEqual('Cannot write another review on this version.') expect(data.error).toEqual('Cannot write another review on this version.')
}) })
it('should return success when creating another recommendation as a HE on the same version when EiC returned manuscript to He ', async () => {
const { noRecommendationHE } = testFixtures.users
const { noEditorRecomedationCollection } = testFixtures.collections
const { noEditorRecomedationFragment } = testFixtures.fragments
const res = await requests.sendRequest({
body,
userId: noRecommendationHE.id,
models,
route,
path,
params: {
collectionId: noEditorRecomedationCollection.id,
fragmentId: noEditorRecomedationFragment.id,
},
})
expect(res.statusCode).toBe(200)
const data = JSON.parse(res._getData())
expect(data.userId).toEqual(noRecommendationHE.id)
})
it('should return an error when an EiC makes a decision on an older version of a manuscript', async () => { it('should return an error when an EiC makes a decision on an older version of a manuscript', async () => {
const { editorInChief } = testFixtures.users const { editorInChief } = testFixtures.users
const { twoVersionsCollection } = testFixtures.collections const { twoVersionsCollection } = testFixtures.collections
......
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