spec.plugins.session.js
This file
Path
spec/spec.plugins.session.js
140 lines · 4.3 KiB · JavaScript
Last changed by
Merge branch 'master' of http://github.com/visionmedia/expressGuillermo Rauchbefore adoption8ef6a0b
History of this fileTake it
The walk stopped after 200 commits: lines older than fbf547d point at it.
Added Session classvisionmediabefore adoptionfbf547d
lines 1–4why, one step back12describe 'Express'3 before_each4 reset()Fixed broken specs due to use(Cookie) missingvisionmediabefore adoption1a9a367
line 5why, one step back5 use(require('express/plugins/cookie').Cookie)Fixed sessions when testingvisionmediabefore adoption4d5a1b5
line 6why, one step back6 use(Session = require('express/plugins/session').Session)Merge branch 'integration'visionmediabefore adoption33443d9
line 7why, one step back7 Base = require('express/plugins/session').BaseFixed sessions when testingvisionmediabefore adoption4d5a1b5
line 8why, one step back8 Session.store.clear()Added Session classvisionmediabefore adoptionfbf547d
lines 9–14why, one step back9 end10 11 describe 'Session'12 describe 'when sid cookie is not present'13 it 'should set sid cookie'14 get('/login', function(){ return '' })Merge branch 'master' of http://github.com/visionmedia/expressGuillermo Rauchbefore adoption8ef6a0b
line 15why, one step back15 get('/login').headers['Set-Cookie'].should.match(/^sid=(\w+);/)Added Session classvisionmediabefore adoptionfbf547d
line 16why, one step back16 endMerge branch 'master' of http://github.com/visionmedia/expressGuillermo Rauchbefore adoption8ef6a0b
lines 17–23why, one step back17 18 describe 'and requesting /favicon.ico'19 it 'should not set sid cookie'20 get('/favicon.ico', function(){ this.respond() })21 get('/favicon.ico').headers.should.not.have_property 'set-cookie'22 end23 endAdded Session classvisionmediabefore adoptionfbf547d
line 24why, one step back24 endMerge branch 'master' of http://github.com/visionmedia/expressGuillermo Rauchbefore adoption8ef6a0b
line 25why, one step back25 Merge branch 'integration'visionmediabefore adoption33443d9
line 26why, one step back26 describe 'when existing sid cookie is present'Added Session classvisionmediabefore adoptionfbf547d
line 27why, one step back27 it 'should not set sid'Merge branch 'integration'visionmediabefore adoption33443d9
line 28why, one step back28 Session.store.commit(new Base(123))Added Session classvisionmediabefore adoptionfbf547d
line 29why, one step back29 get('/login', function(){ return '' })Merge branch 'master' of http://github.com/visionmedia/expressGuillermo Rauchbefore adoption8ef6a0b
line 30why, one step back30 get('/login', { headers: { cookie: 'sid=123' }}).headers.should.not.have_property 'Set-Cookie'Added Session classvisionmediabefore adoptionfbf547d
lines 31–32why, one step back31 end32 endMerge branch 'integration'visionmediabefore adoption33443d9
lines 33–38why, one step back33 34 describe 'when unknown sid cookie is present'35 it 'should set new sid'36 get('/login', function(){ return '' })37 var headers= get('/login', { headers: { cookie: 'sid=123' }}).headers38 Merge branch 'master' of http://github.com/visionmedia/expressGuillermo Rauchbefore adoption8ef6a0b
line 39why, one step back39 headers.should.have_property 'Set-Cookie'Merge branch 'integration'visionmediabefore adoption33443d9
lines 40–43why, one step back40 headers['set-cookie'].should.not.be '123'41 end42 end 43Merge branch 'cache-lifetime'visionmediabefore adoption5ce1306
line 44why, one step back44 describe 'session Store.Memory'Added session reapingvisionmediabefore adoption8ed99f6
line 45why, one step back45 before_eachMerge branch 'integration'visionmediabefore adoption33443d9
line 46why, one step back46 Session.store= memory = new (require('express/plugins/session').Store.Memory)Added session reapingvisionmediabefore adoption8ed99f6
lines 47–48why, one step back47 end48 Added Session classvisionmediabefore adoptionfbf547d
lines 49–55why, one step back49 it 'should persist'50 post('/login', function(){51 return this.session.name = 'tj'52 })53 get('/login', function(){54 return this.session.name55 })Merge branch 'integration'visionmediabefore adoption33443d9
line 56why, one step back56 memory.commit(new Base(123))Added Session classvisionmediabefore adoptionfbf547d
lines 57–61why, one step back57 var headers = { headers: { cookie: 'sid=123' }}58 post('/login', headers)59 get('/login', headers).status.should.eql 20060 get('/login', headers).body.should.eql 'tj'61 endAdded session reapingvisionmediabefore adoption8ed99f6
line 62why, one step back62 Merge branch 'abstract-session'visionmediabefore adoption315c050
lines 63–68why, one step back63 describe '#toString()'64 it 'should return [Memory Store]'65 memory.toString().should.eql '[Memory Store]'66 end67 end68 Added session reapingvisionmediabefore adoption8ed99f6
lines 69–71why, one step back69 describe '#fetch()'70 describe 'when the session does not exist'71 it 'should return a new Session'Merge branch 'integration'visionmediabefore adoption33443d9
lines 72–76why, one step back72 var result73 memory.fetch('1', function(error,session){74 result= session75 })76 result.should.have_property 'lastAccess'Added session reapingvisionmediabefore adoption8ed99f6
lines 77–81why, one step back77 end78 end79 80 describe 'when the session does exist'81 it 'should return the previous session'Merge branch 'integration'visionmediabefore adoption33443d9
lines 82–87why, one step back82 var result83 memory.commit(new Base('1'))84 memory.fetch('1', function(error, session){85 result = session86 })87 result.id.should.eql '1'Added session reapingvisionmediabefore adoption8ed99f6
lines 88–101why, one step back88 end89 end90 end91 92 describe '#clear()'93 it 'should remove all sessions'94 memory.commit({ id: '1' })95 memory.commit({ id: '2' })96 memory.clear()97 memory.should.not.have_property '1'98 memory.should.not.have_property '2'99 end100 end101 Merge branch 'session-count'visionmediabefore adoptione083321
lines 102–103why, one step back102 describe '#length()'103 it 'should return the number of session'Merge branch 'integration'visionmediabefore adoption33443d9
line 104why, one step back104 var lengthMerge branch 'session-count'visionmediabefore adoptione083321
lines 105–106why, one step back105 memory.commit({ id: '1' })106 memory.commit({ id: '2' })Merge branch 'integration'visionmediabefore adoption33443d9
lines 107–110why, one step back107 memory.length(function(error, len) {108 length = len109 })110 length.should.eql 2Merge branch 'session-count'visionmediabefore adoptione083321
lines 111–113why, one step back111 end112 end113 Added session reapingvisionmediabefore adoption8ed99f6
lines 114–136why, one step back114 describe '#destroy()'115 it 'should destroy a single session'116 memory.commit({ id: '1' })117 memory.commit({ id: '2' })118 memory.destroy('1')119 memory.store.should.not.have_property '1'120 memory.store.should.have_property '2'121 end122 end123 124 describe '#reap()'125 it 'should destroy sessions older than the given age in milliseconds'126 memory.commit({ id: '1', lastAccess: Number(new Date) - 300 })127 memory.commit({ id: '2', lastAccess: Number(new Date) - 250 })128 memory.commit({ id: '3', lastAccess: Number(new Date) - 100 })129 memory.commit({ id: '4', lastAccess: Number(new Date) })130 memory.reap(200)131 memory.store.should.not.have_property '1'132 memory.store.should.not.have_property '2'133 memory.store.should.have_property '3'134 memory.store.should.have_property '4'135 end136 endAdded Session classvisionmediabefore adoptionfbf547d
line 137why, one step back137 endAdded session reapingvisionmediabefore adoption8ed99f6
line 138why, one step back138 Added Session classvisionmediabefore adoptionfbf547d
lines 139–140why, one step back139 end140end