Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed redirect handling. Includes tests

  • Loading branch information...
commit c0096236bf28d70eda8c5a2b13ae6f160a1ffe41 1 parent 8672459
Reuven V. Gonzales authored December 04, 2012
2  lib/test.js
@@ -120,7 +120,7 @@ Test.prototype.expect = function(a, b, c){
120 120
 Test.prototype.end = function(fn){
121 121
   var self = this;
122 122
   var end = Request.prototype.end;
123  
-  end.call(this, function(res){
  123
+  end.call(this, function(err, res){
124 124
     self.assert(res, fn);
125 125
   });
126 126
   return this;
30  test/supertest.js
@@ -119,6 +119,36 @@ describe('request(app)', function(){
119 119
     .expect(302, done);
120 120
   })
121 121
 
  122
+  it('should redirect many times', function(done){
  123
+    var app = express();
  124
+
  125
+    app.get('/', function(req, res){
  126
+      res.redirect('/redirect1');
  127
+    });
  128
+    
  129
+    app.get('/redirect1', function(req, res){
  130
+      res.redirect('/redirect2');
  131
+    });
  132
+    
  133
+    app.get('/redirect2', function(req, res){
  134
+      res.redirect('/redirect3');
  135
+    });
  136
+
  137
+    app.get('/redirect3', function(req, res){
  138
+      res.send(200, 'Redirected 3 times');
  139
+    });
  140
+
  141
+    request(app)
  142
+    .get('/')
  143
+    .redirects(5)
  144
+    .end(function(err, res) {
  145
+      res.should.have.status(200);
  146
+      res.redirects.should.have.length(3);
  147
+      res.text.should.equal('Redirected 3 times');
  148
+      done()
  149
+    });
  150
+  })
  151
+
122 152
   describe('.expect(status[, fn])', function(){
123 153
     it('should assert the response status', function(done){
124 154
       var app = express();

0 notes on commit c009623

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