Refactor project name validation into one place and restrict /s

This commit is contained in:
James Allen
2017-05-19 17:42:24 +01:00
parent b0b75e2ebb
commit ba62206b91
18 changed files with 201 additions and 110 deletions
@@ -280,20 +280,12 @@ describe "ProjectController", ->
done()
@ProjectController.renameProject @req, @res
it "should send a 500 if there is a problem", (done)->
@EditorController.renameProject.callsArgWith(2, "problem")
@res.sendStatus = (code)=>
code.should.equal 500
@EditorController.renameProject.calledWith(@project_id, @newProjectName).should.equal true
it "should send an error to next() if there is a problem", (done)->
@EditorController.renameProject.callsArgWith(2, error = new Error("problem"))
next = (e)=>
e.should.equal error
done()
@ProjectController.renameProject @req, @res
it "should return an error if the name is over 150 chars", (done)->
@req.body.newProjectName = "EDMUBEEBKBXUUUZERMNSXFFWIBHGSDAWGMRIQWJBXGWSBVWSIKLFPRBYSJEKMFHTRZBHVKJSRGKTBHMJRXPHORFHAKRNPZGGYIOTEDMUBEEBKBXUUUZERMNSXFFWIBHGSDAWGMRIQWJBXGWSBVWSIKLFPRBYSJEKMFHTRZBHVKJSRGKTBHMJRXPHORFHAKRNPZGGYIOT"
@res.sendStatus = (code)=>
code.should.equal 400
done()
@ProjectController.renameProject @req, @res
@ProjectController.renameProject @req, @res, next
describe "loadEditor", ->
beforeEach ->