mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-23 08:57:51 +00:00
replaced all mongoose Project.find with mongojs calls
This commit is contained in:
parent
b6d62a677b
commit
586d4cbae1
2 changed files with 14 additions and 17 deletions
services/web
app/coffee/Features/Project
test/UnitTests/coffee/Project
|
@ -75,7 +75,7 @@ module.exports = ProjectEntityHandler =
|
|||
documentUpdaterHandler = require('../../Features/DocumentUpdater/DocumentUpdaterHandler')
|
||||
documentUpdaterHandler.flushProjectToMongo project_id, (error) ->
|
||||
return callback(error) if error?
|
||||
Project.findById project_id, (error, project) ->
|
||||
ProjectGetter.getProject project_id, (error, project) ->
|
||||
return callback(error) if error?
|
||||
requests = []
|
||||
self.getAllDocs project_id, (error, docs) ->
|
||||
|
@ -279,7 +279,7 @@ module.exports = ProjectEntityHandler =
|
|||
logger.err err: "No entityType set", project_id: project_id, entity_id: entity_id
|
||||
return callback("No entityType set")
|
||||
entityType = entityType.toLowerCase()
|
||||
Project.findById project_id, (err, project)=>
|
||||
ProjectGetter.getProject project_id, (err, project)=>
|
||||
return callback(err) if err?
|
||||
projectLocator.findElement {project:project, element_id:entity_id, type:entityType}, (err, entity, path)->
|
||||
return callback(err) if err?
|
||||
|
@ -317,7 +317,7 @@ module.exports = ProjectEntityHandler =
|
|||
logger.err err: "No entityType set", project_id: project_id, entity_id: entity_id
|
||||
return callback("No entityType set")
|
||||
entityType = entityType.toLowerCase()
|
||||
Project.findById project_id, (err, project)=>
|
||||
ProjectGetter.getProject project_id, (err, project)=>
|
||||
return callback(error) if error?
|
||||
projectLocator.findElement {project: project, element_id: entity_id, type: entityType}, (error, entity, path)=>
|
||||
return callback(error) if error?
|
||||
|
@ -336,7 +336,7 @@ module.exports = ProjectEntityHandler =
|
|||
logger.err err: "No entityType set", project_id: project_id, entity_id: entity_id
|
||||
return callback("No entityType set")
|
||||
entityType = entityType.toLowerCase()
|
||||
Project.findById project_id, (err, project)=>
|
||||
ProjectGetter.getProject project_id, (err, project)=>
|
||||
projectLocator.findElement {project:project, element_id:entity_id, type:entityType}, (err, entity, path, folder)=>
|
||||
if err?
|
||||
return callback err
|
||||
|
|
|
@ -144,6 +144,7 @@ describe 'ProjectEntityHandler', ->
|
|||
describe 'deleteEntity', ->
|
||||
entity_id = "4eecaffcbffa66588e000009"
|
||||
beforeEach ->
|
||||
@ProjectGetter.getProject.callsArgWith(1, null, @project)
|
||||
@tpdsUpdateSender.deleteEntity = sinon.stub().callsArg(1)
|
||||
@ProjectEntityHandler._removeElementFromMongoArray = sinon.stub().callsArg(3)
|
||||
@ProjectEntityHandler._cleanUpEntity = sinon.stub().callsArg(3)
|
||||
|
@ -231,6 +232,7 @@ describe 'ProjectEntityHandler', ->
|
|||
}
|
||||
@ProjectEntityHandler._removeElementFromMongoArray = sinon.stub().callsArg(3)
|
||||
@ProjectEntityHandler._putElement = sinon.stub().callsArgWith(4, null, path: @pathAfterMove)
|
||||
@ProjectGetter.getProject.callsArgWith(1, null, @project)
|
||||
@tpdsUpdateSender.moveEntity = sinon.stub().callsArg(1)
|
||||
|
||||
describe "moving a doc", ->
|
||||
|
@ -567,7 +569,7 @@ describe 'ProjectEntityHandler', ->
|
|||
@ProjectModel.update = (conditions, update, options, callback)=>
|
||||
conditions._id.should.equal project_id
|
||||
differenceInMs = update.$set["#{@filePaths.mongo}.created"].getTime() - d.getTime()
|
||||
differenceInMs.should.be.below(10)
|
||||
differenceInMs.should.be.below(20)
|
||||
done()
|
||||
|
||||
@ProjectEntityHandler.replaceFile project_id, @file_id, @fsPath, =>
|
||||
|
@ -808,27 +810,21 @@ describe 'ProjectEntityHandler', ->
|
|||
@ProjectEntityHandler.getAllDocs = sinon.stub().callsArgWith(1, null, @docs)
|
||||
@ProjectEntityHandler.getAllFiles = sinon.stub().callsArgWith(1, null, @files)
|
||||
|
||||
@ProjectGetter.getProject.callsArgWith(1, null, @project)
|
||||
|
||||
@ProjectEntityHandler.flushProjectToThirdPartyDataStore project_id, () -> done()
|
||||
|
||||
it "should flush the project from the doc updater", ->
|
||||
@documentUpdaterHandler.flushProjectToMongo
|
||||
.calledWith(project_id)
|
||||
.should.equal true
|
||||
@documentUpdaterHandler.flushProjectToMongo.calledWith(project_id).should.equal true
|
||||
|
||||
it "should look up the project in mongo", ->
|
||||
@ProjectModel.findById
|
||||
.calledWith(project_id)
|
||||
.should.equal true
|
||||
@ProjectGetter.getProject.calledWith(project_id).should.equal true
|
||||
|
||||
it "should get all the docs in the project", ->
|
||||
@ProjectEntityHandler.getAllDocs
|
||||
.calledWith(project_id)
|
||||
.should.equal true
|
||||
@ProjectEntityHandler.getAllDocs.calledWith(project_id).should.equal true
|
||||
|
||||
it "should get all the files in the project", ->
|
||||
@ProjectEntityHandler.getAllFiles
|
||||
.calledWith(project_id)
|
||||
.should.equal true
|
||||
@ProjectEntityHandler.getAllFiles.calledWith(project_id).should.equal true
|
||||
|
||||
it "should flush each doc to the TPDS", ->
|
||||
for path, doc of @docs
|
||||
|
@ -931,6 +927,7 @@ describe 'ProjectEntityHandler', ->
|
|||
@projectLocator.findElement = sinon.stub().callsArgWith(1, null, @entity = { _id: @entity_id, name:"old.tex", rev:4 }, @path)
|
||||
@ProjectModel.update = sinon.stub().callsArgWith(3)
|
||||
@tpdsUpdateSender.moveEntity = sinon.stub()
|
||||
@ProjectGetter.getProject.callsArgWith(1, null, @project)
|
||||
|
||||
it "should update the name in mongo", (done)->
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue