Skip to content

Commit

Permalink
fix serverSide redirectTo with rootPath != default
Browse files Browse the repository at this point in the history
  • Loading branch information
c089 committed Jan 16, 2014
1 parent 974d5e8 commit 2cead8a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions server/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ ServerRouter.prototype.getHandler = function(action, pattern, route) {
currentRoute: route,
app: app,
redirectTo: function(uri, options) {
uri = (app.get('rootPath') || '') + uri;
if (options !== undefined && options.status) {
res.redirect(options.status, uri);
}
Expand Down
13 changes: 13 additions & 0 deletions test/server/router.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ describe("server/router", function() {
beforeEach(function () {
rendrRoute = { controller: 'users', action: 'show' },
res = { redirect: sinon.spy() };
this.req.rendrApp.get = sinon.stub();
});

function createHandler(options) {
Expand All @@ -456,6 +457,18 @@ describe("server/router", function() {
res.redirect.should.have.been.calledWithExactly(301, '/some_uri');
res.redirect.should.have.been.calledOn(res);
});

it("should redirect to the correct path with a rootPath set", function () {
var handler = createHandler();
this.req.rendrApp.get.withArgs('rootPath').returns('/myRoot');

handler(this.req, res);

res.redirect.should.have.been.calledOnce;
res.redirect.should.have.been.calledWithExactly('/myRoot/some_uri');
res.redirect.should.have.been.calledOn(res);
});

});
});
});
Expand Down

0 comments on commit 2cead8a

Please sign in to comment.