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')
|
projectOptionsHandler = require('./ProjectOptionsHandler')
|
||||||
DocumentUpdaterHandler = require("../DocumentUpdater/DocumentUpdaterHandler")
|
DocumentUpdaterHandler = require("../DocumentUpdater/DocumentUpdaterHandler")
|
||||||
DocstoreManager = require "../Docstore/DocstoreManager"
|
DocstoreManager = require "../Docstore/DocstoreManager"
|
||||||
|
ProjectGetter = require("./ProjectGetter")
|
||||||
Project = require("../../models/Project").Project
|
Project = require("../../models/Project").Project
|
||||||
_ = require('underscore')
|
_ = require('underscore')
|
||||||
async = require('async')
|
async = require('async')
|
||||||
|
@ -12,7 +13,7 @@ module.exports =
|
||||||
duplicate: (owner, originalProjectId, newProjectName, callback)->
|
duplicate: (owner, originalProjectId, newProjectName, callback)->
|
||||||
DocumentUpdaterHandler.flushProjectToMongo originalProjectId, (err) ->
|
DocumentUpdaterHandler.flushProjectToMongo originalProjectId, (err) ->
|
||||||
return callback(err) if err?
|
return callback(err) if err?
|
||||||
Project.findById originalProjectId, (err, originalProject) ->
|
ProjectGetter.getProject originalProjectId, (err, originalProject) ->
|
||||||
return callback(err) if err?
|
return callback(err) if err?
|
||||||
projectCreationHandler.createBlankProject owner._id, newProjectName, (err, newProject)->
|
projectCreationHandler.createBlankProject owner._id, newProjectName, (err, newProject)->
|
||||||
return callback(err) if err?
|
return callback(err) if err?
|
||||||
|
|
|
@ -75,6 +75,9 @@ describe 'ProjectDuplicator', ->
|
||||||
@Project =
|
@Project =
|
||||||
findById: sinon.stub().callsArgWith(1, null, @project)
|
findById: sinon.stub().callsArgWith(1, null, @project)
|
||||||
|
|
||||||
|
@ProjectGetter =
|
||||||
|
getProject: sinon.stub().callsArgWith(1, null, @project)
|
||||||
|
|
||||||
@duplicator = SandboxedModule.require modulePath, requires:
|
@duplicator = SandboxedModule.require modulePath, requires:
|
||||||
'../../models/Project':{Project:@Project}
|
'../../models/Project':{Project:@Project}
|
||||||
"../DocumentUpdater/DocumentUpdaterHandler": @DocumentUpdaterHandler
|
"../DocumentUpdater/DocumentUpdaterHandler": @DocumentUpdaterHandler
|
||||||
|
@ -83,12 +86,13 @@ describe 'ProjectDuplicator', ->
|
||||||
'./ProjectLocator': @locator
|
'./ProjectLocator': @locator
|
||||||
'./ProjectOptionsHandler': @projectOptionsHandler
|
'./ProjectOptionsHandler': @projectOptionsHandler
|
||||||
"../Docstore/DocstoreManager": @DocstoreManager
|
"../Docstore/DocstoreManager": @DocstoreManager
|
||||||
|
"./ProjectGetter":@ProjectGetter
|
||||||
'logger-sharelatex':{log:->}
|
'logger-sharelatex':{log:->}
|
||||||
|
|
||||||
it "should look up the original project", (done) ->
|
it "should look up the original project", (done) ->
|
||||||
newProjectName = "someProj"
|
newProjectName = "someProj"
|
||||||
@duplicator.duplicate @owner, @project_id, newProjectName, (err, newProject)=>
|
@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()
|
done()
|
||||||
|
|
||||||
it "should flush the original project to mongo", (done) ->
|
it "should flush the original project to mongo", (done) ->
|
||||||
|
|
Loading…
Reference in a new issue