Browse files

Added root url helper

  • Loading branch information...
1 parent c62ed55 commit ebacbebcc622f35a55437891d62cfaeaff38655d @1602 committed Jan 25, 2012
Showing with 18 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +4 −0 lib/railway_routes.js
  3. +13 −0 test/railway_routes_test.js
View
1 .gitignore
@@ -0,0 +1 @@
+node_modules
View
4 lib/railway_routes.js
@@ -49,6 +49,10 @@ Map.prototype.urlHelperName = function (path, action) {
return helperName.join('_');
};
+Map.prototype.root = function (handler, middleware, options) {
+ this.get('/', handler, middleware, options);
+};
+
['get', 'post', 'put', 'delete', 'del', 'all'].forEach(function (method) {
Map.prototype[method] = function (subpath, handler, middleware, options) {
View
13 test/railway_routes_test.js
@@ -122,3 +122,16 @@ it('should allow overwrite path and helper', function (test) {
test.equal(map.pathTo.picture(1602), '/pictures/1602');
test.done();
});
+
+it('should handle root url', function (test) {
+ var paths = [];
+ var map = new routes.Map(fakeApp(paths), fakeBridge());
+ map.root('dashboard#home');
+ test.deepEqual(paths, [
+ [ 'GET', '/', 'dashboard#home' ]
+ ]);
+ test.equal(map.pathTo.root, '/');
+ test.equal(map.pathTo.root(), '/');
+ test.done();
+});
+

0 comments on commit ebacbeb

Please sign in to comment.