Skip to content

Commit

Permalink
added options test
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed May 25, 2011
1 parent 5b33788 commit f15eb6d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ Router.prototype._optionsFor = function(path){
var self = this;
return methods.filter(function(method){
var routes = self.routes[method];
if (!routes) return;
if (!routes || 'options' == method) return;
for (var i = 0, len = routes.length; i < len; ++i) {
if (routes[i].match(path)) return true;
}
Expand Down
21 changes: 21 additions & 0 deletions test/router.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,5 +277,26 @@ module.exports = {
assert.response(app,
{ url: '/Account' },
{ body: 'Account' });
},

'override OPTIONS default': function(){
var app = express.createServer();

app.get('/', function(req, res, next){

});

app.options('/foo', function(req, res, next){
res.header('Allow', 'GET')
res.send('whatever');
});

assert.response(app,
{ url: '/', method: 'OPTIONS' },
{ body: 'GET', headers: { Allow: 'GET' }});

assert.response(app,
{ url: '/foo', method: 'OPTIONS' },
{ body: 'whatever', headers: { Allow: 'GET' }});
}
};

0 comments on commit f15eb6d

Please sign in to comment.