moved clone project from old proj controller to new one with test

This commit is contained in:
Henry Oswald
2014-04-08 14:53:33 +01:00
parent 5b757ac7ab
commit 6f84f4214f
4 changed files with 39 additions and 24 deletions
@@ -10,19 +10,31 @@ describe "ProjectController", ->
beforeEach ->
@project_id = "123213jlkj9kdlsaj"
@settings = {}
@ProjectDeleter =
deleteProject: sinon.stub().callsArgWith(1)
@ProjectDuplicator =
duplicate: sinon.stub().callsArgWith(3, null, {_id:@project_id})
@ProjectController = SandboxedModule.require modulePath, requires:
"settings-sharelatex":@settings
"logger-sharelatex": log:->
"./ProjectDeleter": @ProjectDeleter
"./ProjectDuplicator": @ProjectDuplicator
@project_id = "123213jlkj9kdlsaj"
@user =
_id:"!£123213kjljkl"
first_name: "bjkdsjfk"
@projectName = "£12321jkj9ujkljds"
@req =
params:
Project_id: @project_id
session:
user: @user
body:
projectName: @projectName
@res = {}
describe "deleteProject", ->
@@ -35,3 +47,12 @@ describe "ProjectController", ->
done()
@ProjectController.deleteProject @req, @res
describe "cloneProject", ->
it "should call the project duplicator", (done)->
@res.send = (json)=>
@ProjectDuplicator.duplicate.calledWith(@user, @project_id, @projectName).should.equal true
json.project_id.should.equal @project_id
done()
@ProjectController.cloneProject @req, @res