mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
move project duplicator to mongojs
This commit is contained in:
parent
6ca69f88ac
commit
eedaa43b58
2 changed files with 7 additions and 2 deletions
|
@ -4,6 +4,7 @@ projectLocator = require('./ProjectLocator')
|
|||
projectOptionsHandler = require('./ProjectOptionsHandler')
|
||||
DocumentUpdaterHandler = require("../DocumentUpdater/DocumentUpdaterHandler")
|
||||
DocstoreManager = require "../Docstore/DocstoreManager"
|
||||
ProjectGetter = require("./ProjectGetter")
|
||||
Project = require("../../models/Project").Project
|
||||
_ = require('underscore')
|
||||
async = require('async')
|
||||
|
@ -12,7 +13,7 @@ module.exports =
|
|||
duplicate: (owner, originalProjectId, newProjectName, callback)->
|
||||
DocumentUpdaterHandler.flushProjectToMongo originalProjectId, (err) ->
|
||||
return callback(err) if err?
|
||||
Project.findById originalProjectId, (err, originalProject) ->
|
||||
ProjectGetter.getProject originalProjectId, (err, originalProject) ->
|
||||
return callback(err) if err?
|
||||
projectCreationHandler.createBlankProject owner._id, newProjectName, (err, newProject)->
|
||||
return callback(err) if err?
|
||||
|
|
|
@ -75,6 +75,9 @@ describe 'ProjectDuplicator', ->
|
|||
@Project =
|
||||
findById: sinon.stub().callsArgWith(1, null, @project)
|
||||
|
||||
@ProjectGetter =
|
||||
getProject: sinon.stub().callsArgWith(1, null, @project)
|
||||
|
||||
@duplicator = SandboxedModule.require modulePath, requires:
|
||||
'../../models/Project':{Project:@Project}
|
||||
"../DocumentUpdater/DocumentUpdaterHandler": @DocumentUpdaterHandler
|
||||
|
@ -83,12 +86,13 @@ describe 'ProjectDuplicator', ->
|
|||
'./ProjectLocator': @locator
|
||||
'./ProjectOptionsHandler': @projectOptionsHandler
|
||||
"../Docstore/DocstoreManager": @DocstoreManager
|
||||
"./ProjectGetter":@ProjectGetter
|
||||
'logger-sharelatex':{log:->}
|
||||
|
||||
it "should look up the original project", (done) ->
|
||||
newProjectName = "someProj"
|
||||
@duplicator.duplicate @owner, @project_id, newProjectName, (err, newProject)=>
|
||||
@Project.findById.calledWith(@project_id).should.equal true
|
||||
@ProjectGetter.getProject.calledWith(@project_id).should.equal true
|
||||
done()
|
||||
|
||||
it "should flush the original project to mongo", (done) ->
|
||||
|
|
Loading…
Reference in a new issue