Skip to content

Commit

Permalink
respect overridoing shared functions for aggregators
Browse files Browse the repository at this point in the history
  • Loading branch information
wheresrhys committed Aug 30, 2016
1 parent d61195b commit 0cb1635
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/aggregator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ queryMethods.mixin(Aggregator.prototype, function (method, methodName) {
// As always, we clone to maintain immutability
return function () {
const aggregator = this.clone();
aggregator.queries = aggregator.queries.map(q => q[methodName].apply(q, [].slice.call(arguments)))
aggregator.sharedFunctions.push({
func: methodName,
params: [].slice.call(arguments)
})

return aggregator;
}
});
Expand Down
11 changes: 11 additions & 0 deletions test/regression.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,15 @@ describe('regression tests', () => {
.then(fetchMock.restore);
});

it('Can override previously called shared method for aggregators', () => {
const kq = KeenQuery.build('@ratio(potato->count(),potato->count())->interval(d)');
const kq2 = kq.interval('h');
return kq2.print('url').then(urls => {
expect(urls[0]).to.contain('hourly')
expect(urls[1]).to.contain('hourly')
})


})

});

0 comments on commit 0cb1635

Please sign in to comment.