mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #1102 from sharelatex/mm-ensure-history-before-export
Ensure project has history before exporting GitOrigin-RevId: 688131fbbca1cd339433d3b9be57a03a32303b3e
This commit is contained in:
parent
365158f283
commit
49acb719db
3 changed files with 10 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
|||
ProjectGetter = require('../Project/ProjectGetter')
|
||||
ProjectHistoryHandler = require('../Project/ProjectHistoryHandler')
|
||||
ProjectLocator = require('../Project/ProjectLocator')
|
||||
ProjectRootDocManager = require('../Project/ProjectRootDocManager')
|
||||
UserGetter = require('../User/UserGetter')
|
||||
|
@ -35,6 +36,8 @@ module.exports = ExportsHandler = self =
|
|||
user: (cb) ->
|
||||
UserGetter.getUser user_id, {first_name: 1, last_name: 1, email: 1, overleaf: 1}, cb
|
||||
historyVersion: (cb) ->
|
||||
ProjectHistoryHandler.ensureHistoryExistsForProject project_id, (error) ->
|
||||
return callback(error) if error?
|
||||
self._requestVersion project_id, cb
|
||||
|
||||
async.auto jobs, (err, results) ->
|
||||
|
|
|
@ -19,7 +19,6 @@ module.exports = ProjectHistoryHandler =
|
|||
getHistoryId: (project_id, callback = (err, result) ->) ->
|
||||
ProjectDetailsHandler.getDetails project_id, (err, project) ->
|
||||
return callback(err) if err? # n.b. getDetails returns an error if the project doesn't exist
|
||||
return callback(new Error("history exists")) if project.overleaf?.history?.id?
|
||||
callback(null, project?.overleaf?.history?.id)
|
||||
|
||||
ensureHistoryExistsForProject: (project_id, callback = (err) ->) ->
|
||||
|
|
|
@ -15,6 +15,7 @@ describe 'ExportsHandler', ->
|
|||
log: ->
|
||||
err: ->
|
||||
'../Project/ProjectGetter': @ProjectGetter = {}
|
||||
'../Project/ProjectHistoryHandler': @ProjectHistoryHandler = {}
|
||||
'../Project/ProjectLocator': @ProjectLocator = {}
|
||||
'../Project/ProjectRootDocManager': @ProjectRootDocManager = {}
|
||||
'../User/UserGetter': @UserGetter = {}
|
||||
|
@ -101,6 +102,7 @@ describe 'ExportsHandler', ->
|
|||
@rootDocPath = 'main.tex'
|
||||
@historyVersion = 777
|
||||
@ProjectGetter.getProject = sinon.stub().yields(null, @project)
|
||||
@ProjectHistoryHandler.ensureHistoryExistsForProject = sinon.stub().yields(null)
|
||||
@ProjectLocator.findRootDoc = sinon.stub().yields(null, [null, {fileSystem: 'main.tex'}])
|
||||
@ProjectRootDocManager.ensureRootDocumentIsSet = sinon.stub().callsArgWith(1, null)
|
||||
@UserGetter.getUser = sinon.stub().yields(null, @user)
|
||||
|
@ -113,6 +115,10 @@ describe 'ExportsHandler', ->
|
|||
@callback(error, export_data)
|
||||
done()
|
||||
|
||||
it "should ensure the project has history", ->
|
||||
@ProjectHistoryHandler.ensureHistoryExistsForProject.called
|
||||
.should.equal true
|
||||
|
||||
it "should request the project history version", ->
|
||||
@ExportsHandler._requestVersion.called
|
||||
.should.equal true
|
||||
|
|
Loading…
Reference in a new issue