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 bad this reference on Channel#closeBecause #298

Merged
merged 1 commit into from
Nov 3, 2016
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/channel_model.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ C.open = function() {
};

C.close = function() {
var self = this;
return Promise.fromCallback(function(cb) {
return this.closeBecause("Goodbye", defs.constants.REPLY_SUCCESS,
return self.closeBecause("Goodbye", defs.constants.REPLY_SUCCESS,
cb);
});
};
Expand Down
8 changes: 7 additions & 1 deletion test/channel_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function channel_test(chmethod, name, chfun) {
c[chmethod]().then(ignoreErrors).then(chfun)
.then(succeed(done), fail(done))
// close the connection regardless of what happens with the test
.then(function() {c.close();});
.finally(function() {c.close();});
});
});
}
Expand Down Expand Up @@ -509,6 +509,12 @@ chtest("prefetch", function(ch) {
});
});

chtest('close', function(ch) {
// Resolving promise guarantees
// channel is closed
return ch.close();
});

});

var confirmtest = channel_test.bind(null, 'createConfirmChannel');
Expand Down