Comparar commits

..

4 Commits

Autor SHA1 Mensagem Data
visionmedia 934adb1e9f Release 0.7.5 2010-03-16 19:38:21 -07:00
visionmedia 50e0593de6 Request#flash() without args now returns all flashes 2010-03-16 19:34:11 -07:00
visionmedia f2637c6421 Fixed Request#flash() specs 2010-03-16 19:22:10 -07:00
visionmedia a52dacea68 Updated ext 2010-03-16 19:12:15 -07:00
7 arquivos alterados com 77 adições e 20 exclusões
+6
Ver Arquivo
@@ -1,4 +1,10 @@
0.7.5 / 2010-03-16
==================
* Added Request#flash() support without args, now returns all flashes
* Updated ext submodule
0.7.4 / 2010-03-16
==================
+1 -1
Ver Arquivo
@@ -314,7 +314,7 @@ Server = new Class({
// --- Express
Express = {
version: '0.7.4',
version: '0.7.5',
config: [],
routes: [],
plugins: [],
+9 -1
Ver Arquivo
@@ -18,6 +18,9 @@ exports.Flash = Plugin.extend({
* it will persist in the session until outputted.
* The _val_ pushed is returned.
*
* When no arguments are given, all flashes are
* returned keyed by their type.
*
* Example:
*
* this.flash('info', 'email sent')
@@ -30,12 +33,17 @@ exports.Flash = Plugin.extend({
*
* @param {string} key
* @param {string} val
* @return {string}
* @return {mixed}
* @api public
*/
flash: function(key, val) {
if (!this.session.flash) this.session.flash = {}
if (!key) {
var flashes = this.session.flash
this.session.flash = {}
return flashes
}
if (!(key in this.session.flash)) this.session.flash[key] = []
if (val)
return this.session.flash[key].push(val), val
+1 -1
Ver Arquivo
@@ -1,7 +1,7 @@
{
"name": "Express",
"description": "Sinatra inspired web development framework",
"version": "0.7.4",
"version": "0.7.5",
"keywords": ["framework", "sinatra", "web", "rest", "restful"],
"directories": {
"lib": "lib"
+1 -1
Ver Arquivo
@@ -1,4 +1,4 @@
---
name: Express
description: Sinatra inspired web development framework
version: 0.7.4
version: 0.7.5
+58 -15
Ver Arquivo
@@ -10,23 +10,66 @@ describe 'Express'
describe 'Flash'
describe 'flash()'
it 'should push a flash message'
var headers = { headers: { cookie: 'sid=123' }}
post('/', function(){ return this.flash('info', 'email sent') })
get('/', function(){ return this.flash('info', 'email received') })
get('/info', function(){ return this.flash('info').join(', ') })
get('/messages', function(){ return this.flash('info') || 'empty' })
post('/', headers).body.should.eql 'email sent'
get('/', headers).body.should.eql 'email received'
get('/info', headers).body.should.eql 'email sent, email received'
get('/messages').body.should.eql 'empty'
// TODO: seperate once segfault is fixed...
describe 'given a type and msg'
it 'should push a flash message'
var headers = { headers: { cookie: 'sid=123' }}
post('/', function(){ return this.flash('info', 'email sent') })
get('/', function(){ return this.flash('info').join(', ') })
post('/', headers)
post('/', headers)
get('/', headers).body.should.eql 'email sent, email sent'
end
end
it 'should return the message pushed'
get('/', function(){ return this.flash('info', 'email sent') })
get('/').body.should.eql 'email sent'
describe 'given a type'
describe 'when no messages have been pushed'
it 'should return null'
var headers = { headers: { cookie: 'sid=123' }}
get('/', function(){ return this.flash('info') || 'empty' })
get('/', headers).body.should.eql 'empty'
end
end
describe 'when messages have been pushed'
it 'should persist only until flushed'
var headers = { headers: { cookie: 'sid=123' }}
post('/', function(){ return this.flash('info', 'email sent') })
get('/', function(){ return (this.flash('info') || ['nope!']).join(', ') })
post('/', headers)
post('/', headers)
get('/', headers).body.should.eql 'email sent, email sent'
get('/', headers).body.should.eql 'nope!'
end
end
describe 'given no arguments'
it 'should provide access to all types'
var flash, headers = { headers: { cookie: 'sid=123' }}
post('/', function(){ return this.flash('info', 'email sent') })
post('/error', function(){ return this.flash('error', 'email failed to send') })
get('/', function(){ return flash = this.flash(), '' })
post('/', headers)
post('/', headers)
post('/error', headers)
get('/')
flash.should.eql { info: ['email sent', 'email sent'], error: ['email failed to send'] }
end
it 'should persist only until flushed'
var flash, headers = { headers: { cookie: 'sid=123' }}
post('/', function(){ return this.flash('info', 'email sent') })
post('/error', function(){ return this.flash('error', 'email failed to send') })
get('/', function(){ return flash = this.flash(), '' })
post('/', headers)
post('/', headers)
post('/error', headers)
get('/', headers)
flash.should.eql { info: ['email sent', 'email sent'], error: ['email failed to send'] }
get('/', headers)
flash.should.eql {}
end
end
end
end
end