mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-29 12:01:32 +02:00
allow getting doc paths by project id
This commit is contained in:
@@ -65,6 +65,12 @@ module.exports = ProjectEntityHandler = self =
|
||||
files.push({path: path.join(folderPath, file.name), file:file})
|
||||
callback null, docs, files
|
||||
|
||||
getAllDocPathsFromProjectById: (project_id, callback) ->
|
||||
ProjectGetter.getProjectWithoutDocLines project_id, (err, project) ->
|
||||
return callback(err) if err?
|
||||
return callback(Errors.NotFoundError("no project")) if !project?
|
||||
self.getAllDocPathsFromProject project, callback
|
||||
|
||||
getAllDocPathsFromProject: (project, callback) ->
|
||||
logger.log project:project, "getting all docs for project"
|
||||
self._getAllFoldersFromProject project, (err, folders = {}) ->
|
||||
|
||||
@@ -33,7 +33,7 @@ module.exports = ProjectRootDocManager =
|
||||
callback()
|
||||
|
||||
setRootDocFromName: (project_id, rootDocName, callback = (error) ->) ->
|
||||
ProjectEntityHandler.getAllDocPathsFromProject project_id, (error, docPaths) ->
|
||||
ProjectEntityHandler.getAllDocPathsFromProjectById project_id, (error, docPaths) ->
|
||||
return callback(error) if error?
|
||||
# find the root doc from the filename
|
||||
root_doc_id = null
|
||||
|
||||
@@ -83,12 +83,12 @@ describe 'ProjectRootDocManager', ->
|
||||
"doc-id-2": "/main.tex"
|
||||
"doc-id-3": "/nested/chapter1a.tex"
|
||||
"doc-id-4": "/nested/chapter1b.tex"
|
||||
@ProjectEntityHandler.getAllDocPathsFromProject = sinon.stub().callsArgWith(1, null, @docPaths)
|
||||
@ProjectEntityHandler.getAllDocPathsFromProjectById = sinon.stub().callsArgWith(1, null, @docPaths)
|
||||
@ProjectEntityUpdateHandler.setRootDoc = sinon.stub().callsArgWith(2)
|
||||
@ProjectRootDocManager.setRootDocFromName @project_id, '/main.tex', done
|
||||
|
||||
it "should check the docs of the project", ->
|
||||
@ProjectEntityHandler.getAllDocPathsFromProject.calledWith(@project_id)
|
||||
@ProjectEntityHandler.getAllDocPathsFromProjectById.calledWith(@project_id)
|
||||
.should.equal true
|
||||
|
||||
it "should set the root doc to main.tex", ->
|
||||
@@ -102,12 +102,12 @@ describe 'ProjectRootDocManager', ->
|
||||
"doc-id-2": "/main.tex"
|
||||
"doc-id-3": "/nested/chapter1a.tex"
|
||||
"doc-id-4": "/nested/chapter1b.tex"
|
||||
@ProjectEntityHandler.getAllDocPathsFromProject = sinon.stub().callsArgWith(1, null, @docPaths)
|
||||
@ProjectEntityHandler.getAllDocPathsFromProjectById = sinon.stub().callsArgWith(1, null, @docPaths)
|
||||
@ProjectEntityUpdateHandler.setRootDoc = sinon.stub().callsArgWith(2)
|
||||
@ProjectRootDocManager.setRootDocFromName @project_id, 'main.tex', done
|
||||
|
||||
it "should check the docs of the project", ->
|
||||
@ProjectEntityHandler.getAllDocPathsFromProject.calledWith(@project_id)
|
||||
@ProjectEntityHandler.getAllDocPathsFromProjectById.calledWith(@project_id)
|
||||
.should.equal true
|
||||
|
||||
it "should set the root doc to main.tex", ->
|
||||
@@ -121,12 +121,12 @@ describe 'ProjectRootDocManager', ->
|
||||
"doc-id-2": "/main.tex"
|
||||
"doc-id-3": "/nested/chapter1a.tex"
|
||||
"doc-id-4": "/nested/chapter1b.tex"
|
||||
@ProjectEntityHandler.getAllDocPathsFromProject = sinon.stub().callsArgWith(1, null, @docPaths)
|
||||
@ProjectEntityHandler.getAllDocPathsFromProjectById = sinon.stub().callsArgWith(1, null, @docPaths)
|
||||
@ProjectEntityUpdateHandler.setRootDoc = sinon.stub().callsArgWith(2)
|
||||
@ProjectRootDocManager.setRootDocFromName @project_id, 'chapter1a.tex', done
|
||||
|
||||
it "should check the docs of the project", ->
|
||||
@ProjectEntityHandler.getAllDocPathsFromProject.calledWith(@project_id)
|
||||
@ProjectEntityHandler.getAllDocPathsFromProjectById.calledWith(@project_id)
|
||||
.should.equal true
|
||||
|
||||
it "should set the root doc using the basename", ->
|
||||
@@ -140,7 +140,7 @@ describe 'ProjectRootDocManager', ->
|
||||
"doc-id-2": "/main.tex"
|
||||
"doc-id-3": "/nested/chapter1a.tex"
|
||||
"doc-id-4": "/nested/chapter1b.tex"
|
||||
@ProjectEntityHandler.getAllDocPathsFromProject = sinon.stub().callsArgWith(1, null, @docPaths)
|
||||
@ProjectEntityHandler.getAllDocPathsFromProjectById = sinon.stub().callsArgWith(1, null, @docPaths)
|
||||
@ProjectEntityUpdateHandler.setRootDoc = sinon.stub().callsArgWith(2)
|
||||
@ProjectRootDocManager.setRootDocFromName @project_id, "other.tex", done
|
||||
|
||||
|
||||
Reference in New Issue
Block a user