Skip to content

Commit

Permalink
Merge pull request #286 from alekbarszczewski/redirects-fix
Browse files Browse the repository at this point in the history
Fixes issue with redirects
  • Loading branch information
mikelax committed Feb 11, 2016
2 parents 96abafa + d29c8ff commit bea0c80
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/test.js
Expand Up @@ -119,7 +119,7 @@ Test.prototype.end = function(fn){
var end = Request.prototype.end;

end.call(this, function(err, res){
if (server) return server.close(assert);
if (server && server._handle) return server.close(assert);

assert();

Expand Down
24 changes: 23 additions & 1 deletion test/supertest.js
Expand Up @@ -161,6 +161,28 @@ describe('request(app)', function(){
.expect(302, done);
});

it('should handle redirects', function(done){
var app = express();

app.get('/login', function (req, res){
res.end('Login')
});

app.get('/', function(req, res){
res.redirect('/login');
});

request(app)
.get('/')
.redirects(1)
.end(function (err, res) {
should.exist(res)
res.status.should.be.equal(200)
res.text.should.be.equal('Login')
done()
})
});

it('should handle socket errors', function(done) {
var app = express();

Expand Down Expand Up @@ -1030,4 +1052,4 @@ describe("request.get(url).query(vals) works as expected", function(){
done();
});
});
});
});

0 comments on commit bea0c80

Please sign in to comment.