Skip to content

Commit

Permalink
Fix tests for options.as parameter
Browse files Browse the repository at this point in the history
The options.as parameter should override the automatic guessing,
not the other way around
  • Loading branch information
fsateler committed Mar 22, 2012
1 parent 08cb1fb commit b04e94a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions test/railway_routes_test.js
Expand Up @@ -116,10 +116,10 @@ it('should allow overwrite path and helper', function (test) {
[ 'PUT', '/pictures/:id.:format?', 'avatars#update' ], [ 'PUT', '/pictures/:id.:format?', 'avatars#update' ],
[ 'GET', '/pictures/:id.:format?', 'avatars#show' ] [ 'GET', '/pictures/:id.:format?', 'avatars#show' ]
]); ]);
test.equal(map.pathTo.pictures, '/pictures'); test.equal(map.pathTo.images, '/pictures');
test.equal(map.pathTo.new_picture, '/pictures/new'); test.equal(map.pathTo.new_image, '/pictures/new');
test.equal(map.pathTo.edit_picture(1), '/pictures/1/edit'); test.equal(map.pathTo.edit_image(1), '/pictures/1/edit');
test.equal(map.pathTo.picture(1602), '/pictures/1602'); test.equal(map.pathTo.image(1602), '/pictures/1602');
test.done(); test.done();
}); });


Expand All @@ -139,10 +139,13 @@ it('should allow to specify url helper name', function (test) {
var paths = []; var paths = [];
var map = new routes.Map(fakeApp(paths), fakeBridge()); var map = new routes.Map(fakeApp(paths), fakeBridge());
map.get('/p/:id', 'posts#show', {as: 'post'}); map.get('/p/:id', 'posts#show', {as: 'post'});
map.get('/p/:id/edit', 'posts#edit', {as: 'post_edit'});
test.deepEqual(paths, [ test.deepEqual(paths, [
[ 'GET', '/p/:id', 'posts#show' ] [ 'GET', '/p/:id', 'posts#show' ],
[ 'GET', '/p/:id/edit', 'posts#edit' ]
]); ]);
test.equal(map.pathTo.post(1), '/p/1'); test.equal(map.pathTo.post(1), '/p/1');
test.equal(map.pathTo.post_edit(1), '/p/1/edit');
test.done(); test.done();
}); });


0 comments on commit b04e94a

Please sign in to comment.