mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #1507 from sharelatex/mm-pubmodal-show-errors
Return error status to the publish modal on export creation error GitOrigin-RevId: e46e9c1244ee540a4687240e8ecbb14ff36bd2e8
This commit is contained in:
parent
1940e9b061
commit
cc613f4370
2 changed files with 17 additions and 10 deletions
|
@ -27,7 +27,8 @@ module.exports =
|
|||
if err?
|
||||
if err.forwardResponse?
|
||||
logger.log {responseError: err.forwardResponse}, "forwarding response"
|
||||
return res.send err.forwardResponse
|
||||
statusCode = err.forwardResponse.status || 500
|
||||
return res.status(statusCode).json err.forwardResponse
|
||||
else
|
||||
return next(err)
|
||||
logger.log
|
||||
|
@ -36,7 +37,7 @@ module.exports =
|
|||
brand_variation_id:brand_variation_id
|
||||
export_v1_id:export_data.v1_id
|
||||
"exported project"
|
||||
res.send export_v1_id: export_data.v1_id
|
||||
res.json export_v1_id: export_data.v1_id
|
||||
|
||||
exportStatus: (req, res) ->
|
||||
{export_id} = req.params
|
||||
|
@ -46,7 +47,7 @@ module.exports =
|
|||
status_summary: 'failed',
|
||||
status_detail: err.toString,
|
||||
}
|
||||
res.send export_json: json
|
||||
res.json export_json: json
|
||||
return err
|
||||
parsed_export = JSON.parse(export_json)
|
||||
json = {
|
||||
|
@ -59,7 +60,7 @@ module.exports =
|
|||
title: parsed_export.title,
|
||||
token: parsed_export.token
|
||||
}
|
||||
res.send export_json: json
|
||||
res.json export_json: json
|
||||
|
||||
exportDownload: (req, res, next) ->
|
||||
{type, export_id} = req.params
|
||||
|
|
|
@ -33,6 +33,11 @@ describe 'ExportsController', ->
|
|||
_id:user_id
|
||||
i18n:
|
||||
translate:->
|
||||
@res =
|
||||
json: sinon.stub()
|
||||
status: sinon.stub()
|
||||
@res.status.returns(@res)
|
||||
@next = sinon.stub()
|
||||
@AuthenticationController =
|
||||
getLoggedInUserId: sinon.stub().returns(@req.session.user._id)
|
||||
@controller = SandboxedModule.require modulePath, requires:
|
||||
|
@ -51,7 +56,7 @@ describe 'ExportsController', ->
|
|||
brand_variation_id: brand_variation_id
|
||||
first_name: firstName
|
||||
last_name: lastName
|
||||
@controller.exportProject @req, send:(body) =>
|
||||
@controller.exportProject @req, json:(body) =>
|
||||
expect(@handler.exportProject.args[0][0]).to.deep.equal expected
|
||||
expect(body).to.deep.equal {export_v1_id: 897}
|
||||
done()
|
||||
|
@ -77,7 +82,7 @@ describe 'ExportsController', ->
|
|||
author: author
|
||||
license: license
|
||||
show_source: show_source
|
||||
@controller.exportProject @req, send:(body) =>
|
||||
@controller.exportProject @req, json:(body) =>
|
||||
expect(@handler.exportProject.args[0][0]).to.deep.equal expected
|
||||
expect(body).to.deep.equal {export_v1_id: 897}
|
||||
done()
|
||||
|
@ -86,9 +91,10 @@ describe 'ExportsController', ->
|
|||
it 'should forward the response onward', (done) ->
|
||||
@error_json = { status: 422, message: 'nope' }
|
||||
@handler.exportProject = sinon.stub().yields({forwardResponse: @error_json})
|
||||
@controller.exportProject @req, send:(body) =>
|
||||
expect(body).to.deep.equal @error_json
|
||||
done()
|
||||
@controller.exportProject @req, @res, @next
|
||||
expect(@res.json.args[0][0]).to.deep.equal @error_json
|
||||
expect(@res.status.args[0][0]).to.equal @error_json.status
|
||||
done()
|
||||
|
||||
it 'should ask the handler to return the status of an export', (done) ->
|
||||
@handler.fetchExport = sinon.stub().yields(
|
||||
|
@ -106,7 +112,7 @@ describe 'ExportsController', ->
|
|||
}")
|
||||
|
||||
@req.params = {project_id: project_id, export_id: 897}
|
||||
@controller.exportStatus @req, send:(body) =>
|
||||
@controller.exportStatus @req, json:(body) =>
|
||||
expect(body).to.deep.equal {export_json: {
|
||||
status_summary: 'completed',
|
||||
status_detail: "all done",
|
||||
|
|
Loading…
Reference in a new issue