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? if err?
logger.log err:err, project_id:project_id, "something went wrong getting project details" logger.log err:err, project_id:project_id, "something went wrong getting project details"
return res.send 500 return res.send 500
res.json(projDetails) req.session.destroy()
res.json(projDetails)

View file

@ -17,17 +17,19 @@ describe 'Project api controller', ->
@req = @req =
params: params:
project_id:@project_id project_id:@project_id
session:
destroy:sinon.stub()
@res = {} @res = {}
@projDetails = {name:"something"}
describe "getProjectDetails", -> describe "getProjectDetails", ->
it "should ask the project details handler for proj details", (done)-> 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)=> @res.json = (data)=>
@ProjectDetailsHandler.getDetails.calledWith(@project_id).should.equal true @ProjectDetailsHandler.getDetails.calledWith(@project_id).should.equal true
data.should.deep.equal projDetails data.should.deep.equal @projDetails
done() done()
@controller.getProjectDetails @req, @res @controller.getProjectDetails @req, @res
@ -37,4 +39,11 @@ describe 'Project api controller', ->
@res.send = (resCode)=> @res.send = (resCode)=>
resCode.should.equal 500 resCode.should.equal 500
done() 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 @controller.getProjectDetails @req, @res