Skip to content

Commit

Permalink
handleOrProxy opts arg is not required
Browse files Browse the repository at this point in the history
  • Loading branch information
jwolski committed Feb 2, 2015
1 parent 2192685 commit 7ffad5e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -832,12 +832,12 @@ RingPop.prototype.handleOrProxy =
key: key,
url: req && req.url
});
this.proxyReq(_.extend(opts, {
this.proxyReq(_.defaults({
key: key,
dest: dest,
req: req,
res: res,
}));
}, opts));
}
};

Expand Down
15 changes: 15 additions & 0 deletions test/index_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
var mock = require('./mock');
var RingPop = require('../index.js');
var test = require('tape');

Expand Down Expand Up @@ -175,3 +176,17 @@ test('protocol join disallows joining different app clusters', function t(assert
assert.end();
});
});

test('no opts does not break handleOrProxy', function t(assert) {
var ringpop = new RingPop({ app: 'ringpop', hostPort: '127.0.0.1:3000' });
ringpop.lookup = function() { return '127.0.0.1:3001'; };
ringpop.requestProxy = mock.requestProxy;

var key = 'KEY0';
var req = {};
var res = {};
var opts = null;
var handleOrProxy = ringpop.handleOrProxy.bind(ringpop, key, req, res, opts);
assert.doesNotThrow(handleOrProxy, null, 'handleOrProxy does not throw');
assert.end();
});

0 comments on commit 7ffad5e

Please sign in to comment.