destroy session when getting project details

This commit is contained in:
Henry Oswald 2014-05-19 12:01:05 +01:00
parent 6f9969d6e1
commit de38cbf595
2 changed files with 15 additions and 4 deletions

View file

@ -10,4 +10,6 @@ module.exports =
if err?
logger.log err:err, project_id:project_id, "something went wrong getting project details"
return res.send 500
req.session.destroy()
res.json(projDetails)

View file

@ -17,17 +17,19 @@ describe 'Project api controller', ->
@req =
params:
project_id:@project_id
session:
destroy:sinon.stub()
@res = {}
@projDetails = {name:"something"}
describe "getProjectDetails", ->
it "should ask the project details handler for proj details", (done)->
projDetails = {name:"something"}
@ProjectDetailsHandler.getDetails.callsArgWith(1, null, projDetails)
@ProjectDetailsHandler.getDetails.callsArgWith(1, null, @projDetails)
@res.json = (data)=>
@ProjectDetailsHandler.getDetails.calledWith(@project_id).should.equal true
data.should.deep.equal projDetails
data.should.deep.equal @projDetails
done()
@controller.getProjectDetails @req, @res
@ -38,3 +40,10 @@ describe 'Project api controller', ->
resCode.should.equal 500
done()
@controller.getProjectDetails @req, @res
it "should destroy the session", (done)->
@ProjectDetailsHandler.getDetails.callsArgWith(1, null, @projDetails)
@res.json = (data)=>
@req.session.destroy.called.should.equal true
done()
@controller.getProjectDetails @req, @res