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

This commit is contained in:
Henry Oswald 2014-04-08 14:34:03 +01:00
parent bc07525d71
commit 5b757ac7ab
3 changed files with 57 additions and 3 deletions

View file

@ -0,0 +1,16 @@
logger = require("logger-sharelatex")
projectDeleter = require("./ProjectDeleter")
module.exports =
deleteProject: (req, res)->
project_id = req.params.Project_id
logger.log project_id:project_id, "deleting project"
projectDeleter.deleteProject project_id, (err)->
if err?
res.send 500
else
res.send 200

View file

@ -1,7 +1,8 @@
UserController = require('./controllers/UserController')
AdminController = require('./Features/ServerAdmin/AdminController')
HomeController = require('./Features/StaticPages/HomeController')
ProjectController = require("./controllers/ProjectController")
OldProjectController = require("./controllers/ProjectController")
ProjectController = require("./Features/Project/ProjectController")
ProjectApiController = require("./Features/Project/ProjectApiController")
InfoController = require('./Features/StaticPages/InfoController')
SpellingController = require('./Features/Spelling/SpellingController')
@ -45,7 +46,7 @@ module.exports = class Router
constructor: (app, io, socketSessions)->
app.use(app.router)
Project = new ProjectController()
Project = new OldProjectController()
app.get '/', HomeController.index
@ -109,7 +110,7 @@ module.exports = class Router
), SecurityManager.requestCanAccessProject, CompileController.getFileFromClsi
app.del "/project/:Project_id/output", SecurityManager.requestCanAccessProject, CompileController.deleteAuxFiles
app.del '/Project/:Project_id', SecurityManager.requestIsOwner, Project.deleteProject
app.del '/Project/:Project_id', SecurityManager.requestIsOwner, ProjectController.deleteProject
app.post '/Project/:Project_id/clone', SecurityManager.requestCanAccessProject, Project.cloneProject
app.post '/Project/:Project_id/snapshot', SecurityManager.requestCanModifyProject, versioningController.takeSnapshot

View file

@ -0,0 +1,37 @@
should = require('chai').should()
SandboxedModule = require('sandboxed-module')
assert = require('assert')
path = require('path')
sinon = require('sinon')
modulePath = path.join __dirname, "../../../../app/js/Features/Project/ProjectController"
expect = require("chai").expect
describe "ProjectController", ->
beforeEach ->
@settings = {}
@ProjectDeleter =
deleteProject: sinon.stub().callsArgWith(1)
@ProjectController = SandboxedModule.require modulePath, requires:
"settings-sharelatex":@settings
"logger-sharelatex": log:->
"./ProjectDeleter": @ProjectDeleter
@project_id = "123213jlkj9kdlsaj"
@req =
params:
Project_id: @project_id
@res = {}
describe "deleteProject", ->
it "should tell the project deleter", (done)->
@res.send = (code)=>
@ProjectDeleter.deleteProject.calledWith(@project_id).should.equal true
code.should.equal 200
done()
@ProjectController.deleteProject @req, @res