Merge pull request #2404 from overleaf/hb-handle-ejp-and-emis-resubmissions

Handle ejp and emis resubmissions

GitOrigin-RevId: 10eb76c5d106f062b8fb171920f09a701d3acfc9
This commit is contained in:
Hugh O'Brien
2019-12-04 10:50:56 +00:00
committed by sharelatex
parent 4ed005b855
commit 01c89d3af2
4 changed files with 41 additions and 8 deletions
@@ -74,7 +74,10 @@ module.exports = {
},
'exported project'
)
return res.json({ export_v1_id: export_data.v1_id })
return res.json({
export_v1_id: export_data.v1_id,
message: export_data.message
})
})
},
@@ -36,11 +36,12 @@ module.exports = ExportsHandler = self = {
if (err != null) {
return callback(err)
}
return self._requestExport(export_data, function(err, export_v1_id) {
return self._requestExport(export_data, function(err, body) {
if (err != null) {
return callback(err)
}
export_data.v1_id = export_v1_id
export_data.v1_id = body.exportId
export_data.message = body.message
// TODO: possibly store the export data in Mongo
return callback(null, export_data)
})
@@ -180,7 +181,7 @@ module.exports = ExportsHandler = self = {
)
return callback(err)
} else if (res.statusCode >= 200 && res.statusCode < 300) {
return callback(null, body.exportId)
return callback(null, body)
} else {
logger.warn(
{ export: export_data },
@@ -94,7 +94,34 @@ describe('ExportsController', function() {
return this.controller.exportProject(this.req, {
json: body => {
expect(this.handler.exportProject.args[0][0]).to.deep.equal(expected)
expect(body).to.deep.equal({ export_v1_id: 897 })
expect(body).to.deep.equal({ export_v1_id: 897, message: undefined })
return done()
}
})
})
})
describe('with a message from v1', function() {
it('should ask the handler to perform the export', function(done) {
this.handler.exportProject = sinon.stub().yields(null, {
iAmAnExport: true,
v1_id: 897,
message: 'RESUBMISSION'
})
const expected = {
project_id,
user_id,
brand_variation_id,
first_name: firstName,
last_name: lastName
}
return this.controller.exportProject(this.req, {
json: body => {
expect(this.handler.exportProject.args[0][0]).to.deep.equal(expected)
expect(body).to.deep.equal({
export_v1_id: 897,
message: 'RESUBMISSION'
})
return done()
}
})
@@ -129,7 +156,7 @@ describe('ExportsController', function() {
return this.controller.exportProject(this.req, {
json: body => {
expect(this.handler.exportProject.args[0][0]).to.deep.equal(expected)
expect(body).to.deep.equal({ export_v1_id: 897 })
expect(body).to.deep.equal({ export_v1_id: 897, message: undefined })
return done()
}
})
@@ -550,8 +550,10 @@ describe('ExportsHandler', function() {
})
})
it('should return the v1 export id', function() {
return this.callback.calledWith(null, this.export_id).should.equal(true)
it('should return the body with v1 export id', function() {
return this.callback
.calledWith(null, { exportId: this.export_id })
.should.equal(true)
})
})