Skip to content
Browse files

[fix test] Ensure that ad-hoc routes added with only options do not c…

…rash director
  • Loading branch information...
1 parent b474c04 commit 6aa296c66ee78a47ec83542f4cabf4534e62c24f @indexzero indexzero committed Jan 5, 2013
Showing with 13 additions and 1 deletion.
  1. +4 −0 lib/director/http/index.js
  2. +9 −1 test/server/http/stream-test.js
View
4 lib/director/http/index.js
@@ -82,6 +82,10 @@ Router.prototype.on = function (method, path) {
}
}
+ if (typeof path !== 'string' && !path.source) {
+ path = '';
+ }
+
director.Router.prototype.on.call(this, method, path, route);
};
View
10 test/server/http/stream-test.js
@@ -21,14 +21,22 @@ vows.describe('director/http/stream').addBatch({
topic: function () {
var router = new director.http.Router();
router.post(/foo\/bar/, { stream: true }, handlers.streamBody);
+ router.path('/a-path', function () {
+ this.post({ stream: true }, handlers.streamBody);
+ });
+
return router;
},
"when passed to an http.Server instance": {
topic: function (router) {
helpers.createServer(router)
.listen(9092, this.callback);
},
- "a POST request to foo/bar": macros.assertPost(9092, 'foo/bar', {
+ "a POST request to /foo/bar": macros.assertPost(9092, 'foo/bar', {
+ foo: 'foo',
+ bar: 'bar'
+ }),
+ "a POST request to /a-path": macros.assertPost(9092, 'a-path', {
foo: 'foo',
bar: 'bar'
})

0 comments on commit 6aa296c

Please sign in to comment.
Something went wrong with that request. Please try again.