Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix options not being initialized in defaults method #1743

Merged
merged 1 commit into from Aug 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions index.js
Expand Up @@ -105,6 +105,8 @@ function wrapRequestMethod (method, options, requester, verb) {
request.defaults = function (options, requester) {
var self = this

options = options || {}

if (typeof options === 'function') {
requester = options
options = {}
Expand Down
8 changes: 8 additions & 0 deletions tests/test-defaults.js
Expand Up @@ -312,6 +312,14 @@ tape('invoke convenience method from defaults', function(t) {
})
})

tape('defaults without options', function(t) {
var d = request.defaults()
d.get(s.url + '/', {json: true}, function (e, r, b) {
t.equal(r.statusCode, 200)
t.end()
})
})

tape('cleanup', function(t) {
s.close(function() {
t.end()
Expand Down