Skip to content

Commit

Permalink
fix bug when syncsPerBidder was set to 0 (#3360)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnellbaker authored and jaiminpanchal27 committed Dec 13, 2018
1 parent 88156e7 commit 4c1f690
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/userSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export function newUserSync(userSyncDependencies) {
if (!bidder) {
return utils.logWarn(`Bidder is required for registering sync`);
}
if (Number(numAdapterBids[bidder]) >= usConfig.syncsPerBidder) {
if (usConfig.syncsPerBidder !== 0 && Number(numAdapterBids[bidder]) >= usConfig.syncsPerBidder) {
return utils.logWarn(`Number of user syncs exceeded for "${bidder}"`);
}

Expand Down
16 changes: 15 additions & 1 deletion test/spec/userSync_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ describe('user sync', function () {
expect(syncUsersSpy.called).to.be.true;
});

it('should limit the sync per bidder', function () {
it('should limit the number of syncs per bidder', function () {
const userSync = newTestUserSync({syncsPerBidder: 2});
userSync.registerSync('image', 'testBidder', 'http://example.com/1');
userSync.registerSync('image', 'testBidder', 'http://example.com/2');
Expand All @@ -148,6 +148,20 @@ describe('user sync', function () {
expect(triggerPixelStub.getCall(2)).to.be.null;
});

it('should not limit the number of syncs per bidder when set to 0', function() {
const userSync = newTestUserSync({syncsPerBidder: 0});
userSync.registerSync('image', 'testBidder', 'http://example.com/1');
userSync.registerSync('image', 'testBidder', 'http://example.com/2');
userSync.registerSync('image', 'testBidder', 'http://example.com/3');
userSync.syncUsers();
expect(triggerPixelStub.getCall(0)).to.not.be.null;
expect(triggerPixelStub.getCall(0).args[0]).to.exist.and.to.match(/^http:\/\/example\.com\/[1|2|3]/);
expect(triggerPixelStub.getCall(1)).to.not.be.null;
expect(triggerPixelStub.getCall(1).args[0]).to.exist.and.to.match(/^http:\/\/example\.com\/[1|2|3]/);
expect(triggerPixelStub.getCall(2)).to.not.be.null;
expect(triggerPixelStub.getCall(2).args[0]).to.exist.and.to.match(/^http:\/\/example\.com\/[1|2|3]/);
});

it('should balance out bidder requests', function () {
const userSync = newTestUserSync();
userSync.registerSync('image', 'atestBidder', 'http://example.com/1');
Expand Down

0 comments on commit 4c1f690

Please sign in to comment.