Skip to content

Commit 6086d8d

Browse files
committed
Merge pull request #5 from tagged/param_cleanliness
Fixes a bug where batched API calls bleed params.
2 parents cbeaa09 + 61ebd46 commit 6086d8d

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@
6262
}
6363

6464
var promise = new Promise(function(resolve, reject) {
65+
var _params = mergeRecursive({}, this._options.params);
66+
6567
this._queue.push({
6668
method: method,
67-
params: mergeRecursive(this._options.params, params || {}),
69+
params: mergeRecursive(_params, params || {}),
6870
deferred: {resolve: resolve, reject: reject}
6971
});
7072

test/unit/lib/index_test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,21 @@ describe('Tagged API', function() {
123123
this.http.post.calledOnce.should.be.true;
124124
});
125125

126+
// WTA-537
127+
it('does not bleed parameters', function() {
128+
this.api.execute("im.send", {
129+
param1: "foo",
130+
param2: "bar"
131+
});
132+
this.api.execute("im.doStuff", {
133+
param3: "bar",
134+
param4: "baz"
135+
});
136+
this.clock.tick(1);
137+
this.http.post.lastCall.args[0].body.should.not.match(/method=im.send.*param3=bar/);
138+
this.http.post.lastCall.args[0].body.should.not.match(/method=im.doStuff.*param1=foo/g);
139+
});
140+
126141
it('makes new post call after clock tick', function() {
127142
var expectedBody = "\nmethod=im.send&param1=foo&param2=bar\n";
128143
this.api.execute("im.send", {

0 commit comments

Comments
 (0)