|
@@ -78,7 +78,7 @@ describe "ProjectController", ->
|
|
|
@EditorController.renameProject = sinon.stub().callsArg(2)
|
|
@EditorController.renameProject = sinon.stub().callsArg(2)
|
|
|
@req.body =
|
|
@req.body =
|
|
|
name: @name = "New name"
|
|
name: @name = "New name"
|
|
|
- @res.send = (code) =>
|
|
|
|
|
|
|
+ @res.sendStatus = (code) =>
|
|
|
@EditorController.renameProject
|
|
@EditorController.renameProject
|
|
|
.calledWith(@project_id, @name)
|
|
.calledWith(@project_id, @name)
|
|
|
.should.equal true
|
|
.should.equal true
|
|
@@ -90,7 +90,7 @@ describe "ProjectController", ->
|
|
|
@EditorController.setCompiler = sinon.stub().callsArg(2)
|
|
@EditorController.setCompiler = sinon.stub().callsArg(2)
|
|
|
@req.body =
|
|
@req.body =
|
|
|
compiler: @compiler = "pdflatex"
|
|
compiler: @compiler = "pdflatex"
|
|
|
- @res.send = (code) =>
|
|
|
|
|
|
|
+ @res.sendStatus = (code) =>
|
|
|
@EditorController.setCompiler
|
|
@EditorController.setCompiler
|
|
|
.calledWith(@project_id, @compiler)
|
|
.calledWith(@project_id, @compiler)
|
|
|
.should.equal true
|
|
.should.equal true
|
|
@@ -102,7 +102,7 @@ describe "ProjectController", ->
|
|
|
@EditorController.setSpellCheckLanguage = sinon.stub().callsArg(2)
|
|
@EditorController.setSpellCheckLanguage = sinon.stub().callsArg(2)
|
|
|
@req.body =
|
|
@req.body =
|
|
|
spellCheckLanguage: @languageCode = "fr"
|
|
spellCheckLanguage: @languageCode = "fr"
|
|
|
- @res.send = (code) =>
|
|
|
|
|
|
|
+ @res.sendStatus = (code) =>
|
|
|
@EditorController.setSpellCheckLanguage
|
|
@EditorController.setSpellCheckLanguage
|
|
|
.calledWith(@project_id, @languageCode)
|
|
.calledWith(@project_id, @languageCode)
|
|
|
.should.equal true
|
|
.should.equal true
|
|
@@ -114,7 +114,7 @@ describe "ProjectController", ->
|
|
|
@EditorController.setPublicAccessLevel = sinon.stub().callsArg(2)
|
|
@EditorController.setPublicAccessLevel = sinon.stub().callsArg(2)
|
|
|
@req.body =
|
|
@req.body =
|
|
|
publicAccessLevel: @publicAccessLevel = "readonly"
|
|
publicAccessLevel: @publicAccessLevel = "readonly"
|
|
|
- @res.send = (code) =>
|
|
|
|
|
|
|
+ @res.sendStatus = (code) =>
|
|
|
@EditorController.setPublicAccessLevel
|
|
@EditorController.setPublicAccessLevel
|
|
|
.calledWith(@project_id, @publicAccessLevel)
|
|
.calledWith(@project_id, @publicAccessLevel)
|
|
|
.should.equal true
|
|
.should.equal true
|
|
@@ -126,7 +126,7 @@ describe "ProjectController", ->
|
|
|
@EditorController.setRootDoc = sinon.stub().callsArg(2)
|
|
@EditorController.setRootDoc = sinon.stub().callsArg(2)
|
|
|
@req.body =
|
|
@req.body =
|
|
|
rootDocId: @rootDocId = "root-doc-id"
|
|
rootDocId: @rootDocId = "root-doc-id"
|
|
|
- @res.send = (code) =>
|
|
|
|
|
|
|
+ @res.sendStatus = (code) =>
|
|
|
@EditorController.setRootDoc
|
|
@EditorController.setRootDoc
|
|
|
.calledWith(@project_id, @rootDocId)
|
|
.calledWith(@project_id, @rootDocId)
|
|
|
.should.equal true
|
|
.should.equal true
|
|
@@ -136,7 +136,7 @@ describe "ProjectController", ->
|
|
|
|
|
|
|
|
describe "deleteProject", ->
|
|
describe "deleteProject", ->
|
|
|
it "should tell the project deleter to archive when forever=false", (done)->
|
|
it "should tell the project deleter to archive when forever=false", (done)->
|
|
|
- @res.send = (code)=>
|
|
|
|
|
|
|
+ @res.sendStatus = (code)=>
|
|
|
@ProjectDeleter.archiveProject.calledWith(@project_id).should.equal true
|
|
@ProjectDeleter.archiveProject.calledWith(@project_id).should.equal true
|
|
|
code.should.equal 200
|
|
code.should.equal 200
|
|
|
done()
|
|
done()
|
|
@@ -144,7 +144,7 @@ describe "ProjectController", ->
|
|
|
|
|
|
|
|
it "should tell the project deleter to delete when forever=true", (done)->
|
|
it "should tell the project deleter to delete when forever=true", (done)->
|
|
|
@req.query = forever: "true"
|
|
@req.query = forever: "true"
|
|
|
- @res.send = (code)=>
|
|
|
|
|
|
|
+ @res.sendStatus = (code)=>
|
|
|
@ProjectDeleter.deleteProject.calledWith(@project_id).should.equal true
|
|
@ProjectDeleter.deleteProject.calledWith(@project_id).should.equal true
|
|
|
code.should.equal 200
|
|
code.should.equal 200
|
|
|
done()
|
|
done()
|
|
@@ -152,7 +152,7 @@ describe "ProjectController", ->
|
|
|
|
|
|
|
|
describe "restoreProject", ->
|
|
describe "restoreProject", ->
|
|
|
it "should tell the project deleter", (done)->
|
|
it "should tell the project deleter", (done)->
|
|
|
- @res.send = (code)=>
|
|
|
|
|
|
|
+ @res.sendStatus = (code)=>
|
|
|
@ProjectDeleter.restoreProject.calledWith(@project_id).should.equal true
|
|
@ProjectDeleter.restoreProject.calledWith(@project_id).should.equal true
|
|
|
code.should.equal 200
|
|
code.should.equal 200
|
|
|
done()
|
|
done()
|
|
@@ -244,7 +244,7 @@ describe "ProjectController", ->
|
|
|
|
|
|
|
|
it "should call the editor controller", (done)->
|
|
it "should call the editor controller", (done)->
|
|
|
@EditorController.renameProject.callsArgWith(2)
|
|
@EditorController.renameProject.callsArgWith(2)
|
|
|
- @res.send = (code)=>
|
|
|
|
|
|
|
+ @res.sendStatus = (code)=>
|
|
|
code.should.equal 200
|
|
code.should.equal 200
|
|
|
@EditorController.renameProject.calledWith(@project_id, @newProjectName).should.equal true
|
|
@EditorController.renameProject.calledWith(@project_id, @newProjectName).should.equal true
|
|
|
done()
|
|
done()
|
|
@@ -252,7 +252,7 @@ describe "ProjectController", ->
|
|
|
|
|
|
|
|
it "should send a 500 if there is a problem", (done)->
|
|
it "should send a 500 if there is a problem", (done)->
|
|
|
@EditorController.renameProject.callsArgWith(2, "problem")
|
|
@EditorController.renameProject.callsArgWith(2, "problem")
|
|
|
- @res.send = (code)=>
|
|
|
|
|
|
|
+ @res.sendStatus = (code)=>
|
|
|
code.should.equal 500
|
|
code.should.equal 500
|
|
|
@EditorController.renameProject.calledWith(@project_id, @newProjectName).should.equal true
|
|
@EditorController.renameProject.calledWith(@project_id, @newProjectName).should.equal true
|
|
|
done()
|
|
done()
|
|
@@ -260,7 +260,7 @@ describe "ProjectController", ->
|
|
|
|
|
|
|
|
it "should return an error if the name is over 150 chars", (done)->
|
|
it "should return an error if the name is over 150 chars", (done)->
|
|
|
@req.body.newProjectName = "EDMUBEEBKBXUUUZERMNSXFFWIBHGSDAWGMRIQWJBXGWSBVWSIKLFPRBYSJEKMFHTRZBHVKJSRGKTBHMJRXPHORFHAKRNPZGGYIOTEDMUBEEBKBXUUUZERMNSXFFWIBHGSDAWGMRIQWJBXGWSBVWSIKLFPRBYSJEKMFHTRZBHVKJSRGKTBHMJRXPHORFHAKRNPZGGYIOT"
|
|
@req.body.newProjectName = "EDMUBEEBKBXUUUZERMNSXFFWIBHGSDAWGMRIQWJBXGWSBVWSIKLFPRBYSJEKMFHTRZBHVKJSRGKTBHMJRXPHORFHAKRNPZGGYIOTEDMUBEEBKBXUUUZERMNSXFFWIBHGSDAWGMRIQWJBXGWSBVWSIKLFPRBYSJEKMFHTRZBHVKJSRGKTBHMJRXPHORFHAKRNPZGGYIOT"
|
|
|
- @res.send = (code)=>
|
|
|
|
|
|
|
+ @res.sendStatus = (code)=>
|
|
|
code.should.equal 400
|
|
code.should.equal 400
|
|
|
done()
|
|
done()
|
|
|
@ProjectController.renameProject @req, @res
|
|
@ProjectController.renameProject @req, @res
|
|
@@ -317,7 +317,7 @@ describe "ProjectController", ->
|
|
|
|
|
|
|
|
it "should not render the page if the project can not be accessed", (done)->
|
|
it "should not render the page if the project can not be accessed", (done)->
|
|
|
@SecurityManager.userCanAccessProject = sinon.stub().callsArgWith 2, false
|
|
@SecurityManager.userCanAccessProject = sinon.stub().callsArgWith 2, false
|
|
|
- @res.send = (resCode, opts)=>
|
|
|
|
|
|
|
+ @res.sendStatus = (resCode, opts)=>
|
|
|
resCode.should.equal 401
|
|
resCode.should.equal 401
|
|
|
done()
|
|
done()
|
|
|
@ProjectController.loadEditor @req, @res
|
|
@ProjectController.loadEditor @req, @res
|