From e51098a496d4bc4591ab21a43dfcf8fad13f267d Mon Sep 17 00:00:00 2001 From: rmartinez Date: Fri, 6 Dec 2019 13:13:07 -0800 Subject: [PATCH 1/2] fix netRev --- modules/rubiconBidAdapter.js | 4 +- test/spec/modules/rubiconBidAdapter_spec.js | 79 ++++++++++++++++++++- 2 files changed, 79 insertions(+), 4 deletions(-) diff --git a/modules/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js index 075eabc208e..03234039b59 100644 --- a/modules/rubiconBidAdapter.js +++ b/modules/rubiconBidAdapter.js @@ -559,7 +559,7 @@ export const spec = { cpm: bid.price || 0, bidderCode: seatbid.seat, ttl: 300, - netRevenue: config.getConfig('rubicon.netRevenue') || true, + netRevenue: config.getConfig('rubicon.netRevenue') !== false, width: bid.w || utils.deepAccess(bidRequest, 'mediaTypes.video.w') || utils.deepAccess(bidRequest, 'params.video.playerWidth'), height: bid.h || utils.deepAccess(bidRequest, 'mediaTypes.video.h') || utils.deepAccess(bidRequest, 'params.video.playerHeight'), }; @@ -639,7 +639,7 @@ export const spec = { cpm: ad.cpm || 0, dealId: ad.deal, ttl: 300, // 5 minutes - netRevenue: config.getConfig('rubicon.netRevenue') || false, + netRevenue: config.getConfig('rubicon.netRevenue') !== false, rubicon: { advertiserId: ad.advertiser, networkId: ad.network }, diff --git a/test/spec/modules/rubiconBidAdapter_spec.js b/test/spec/modules/rubiconBidAdapter_spec.js index c0ed4245cbf..c9921494e59 100644 --- a/test/spec/modules/rubiconBidAdapter_spec.js +++ b/test/spec/modules/rubiconBidAdapter_spec.js @@ -1760,7 +1760,7 @@ describe('the rubicon adapter', function () { expect(bids[0].height).to.equal(50); expect(bids[0].cpm).to.equal(0.911); expect(bids[0].ttl).to.equal(300); - expect(bids[0].netRevenue).to.equal(false); + expect(bids[0].netRevenue).to.equal(true); expect(bids[0].rubicon.advertiserId).to.equal(7); expect(bids[0].rubicon.networkId).to.equal(8); expect(bids[0].creativeId).to.equal('crid-9'); @@ -1775,7 +1775,7 @@ describe('the rubicon adapter', function () { expect(bids[1].height).to.equal(250); expect(bids[1].cpm).to.equal(0.811); expect(bids[1].ttl).to.equal(300); - expect(bids[1].netRevenue).to.equal(false); + expect(bids[1].netRevenue).to.equal(true); expect(bids[1].rubicon.advertiserId).to.equal(7); expect(bids[1].rubicon.networkId).to.equal(8); expect(bids[1].creativeId).to.equal('crid-9'); @@ -1787,6 +1787,81 @@ describe('the rubicon adapter', function () { expect(bids[1].rubiconTargeting.rpfl_14062).to.equal('15_tier_all_test'); }); + it('should pass netRevenue as false if set in setConfig', function () { + config.setConfig({ + rubicon: { + netRevenue: false + } + }); + + let response = { + 'status': 'ok', + 'account_id': 14062, + 'site_id': 70608, + 'zone_id': 530022, + 'size_id': 15, + 'alt_size_ids': [ + 43 + ], + 'tracking': '', + 'inventory': {}, + 'ads': [ + { + 'status': 'ok', + 'impression_id': '153dc240-8229-4604-b8f5-256933b9374c', + 'size_id': '15', + 'ad_id': '6', + 'advertiser': 7, + 'network': 8, + 'creative_id': 'crid-9', + 'type': 'script', + 'script': 'alert(\'foo\')', + 'campaign_id': 10, + 'cpm': 0.811, + 'targeting': [ + { + 'key': 'rpfl_14062', + 'values': [ + '15_tier_all_test' + ] + } + ] + }, + { + 'status': 'ok', + 'impression_id': '153dc240-8229-4604-b8f5-256933b9374d', + 'size_id': '43', + 'ad_id': '7', + 'advertiser': 7, + 'network': 8, + 'creative_id': 'crid-9', + 'type': 'script', + 'script': 'alert(\'foo\')', + 'campaign_id': 10, + 'cpm': 0.911, + 'targeting': [ + { + 'key': 'rpfl_14062', + 'values': [ + '43_tier_all_test' + ] + } + ] + } + ] + }; + + let bids = spec.interpretResponse({body: response}, { + bidRequest: bidderRequest.bids[0] + }); + + expect(bids).to.be.lengthOf(2); + expect(bids[0].netRevenue).to.equal(false); + expect(bids[1].netRevenue).to.equal(false); + + console.log('\n\nTEST OVER!!!\n\n'); + config.resetConfig(); + }); it('should use "network-advertiser" if no creative_id', function () { let response = { 'status': 'ok', From 2c2ae03c39a07837f6ee38ab02fadffcd7995bab Mon Sep 17 00:00:00 2001 From: rmartinez Date: Mon, 9 Dec 2019 09:34:22 -0800 Subject: [PATCH 2/2] adding comments and more tests --- modules/rubiconBidAdapter.js | 4 +- test/spec/modules/rubiconBidAdapter_spec.js | 55 +++++++++++++++++---- 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/modules/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js index 03234039b59..f42ed0be5b6 100644 --- a/modules/rubiconBidAdapter.js +++ b/modules/rubiconBidAdapter.js @@ -559,7 +559,7 @@ export const spec = { cpm: bid.price || 0, bidderCode: seatbid.seat, ttl: 300, - netRevenue: config.getConfig('rubicon.netRevenue') !== false, + netRevenue: config.getConfig('rubicon.netRevenue') !== false, // If anything other than false, netRev is true width: bid.w || utils.deepAccess(bidRequest, 'mediaTypes.video.w') || utils.deepAccess(bidRequest, 'params.video.playerWidth'), height: bid.h || utils.deepAccess(bidRequest, 'mediaTypes.video.h') || utils.deepAccess(bidRequest, 'params.video.playerHeight'), }; @@ -639,7 +639,7 @@ export const spec = { cpm: ad.cpm || 0, dealId: ad.deal, ttl: 300, // 5 minutes - netRevenue: config.getConfig('rubicon.netRevenue') !== false, + netRevenue: config.getConfig('rubicon.netRevenue') !== false, // If anything other than false, netRev is true rubicon: { advertiserId: ad.advertiser, networkId: ad.network }, diff --git a/test/spec/modules/rubiconBidAdapter_spec.js b/test/spec/modules/rubiconBidAdapter_spec.js index c9921494e59..c6941584652 100644 --- a/test/spec/modules/rubiconBidAdapter_spec.js +++ b/test/spec/modules/rubiconBidAdapter_spec.js @@ -1787,13 +1787,7 @@ describe('the rubicon adapter', function () { expect(bids[1].rubiconTargeting.rpfl_14062).to.equal('15_tier_all_test'); }); - it('should pass netRevenue as false if set in setConfig', function () { - config.setConfig({ - rubicon: { - netRevenue: false - } - }); - + it('should pass netRevenue correctly if set in setConfig', function () { let response = { 'status': 'ok', 'account_id': 14062, @@ -1851,15 +1845,58 @@ describe('the rubicon adapter', function () { ] }; + // Set to false => false + config.setConfig({ + rubicon: { + netRevenue: false + } + }); let bids = spec.interpretResponse({body: response}, { bidRequest: bidderRequest.bids[0] }); - expect(bids).to.be.lengthOf(2); expect(bids[0].netRevenue).to.equal(false); expect(bids[1].netRevenue).to.equal(false); - console.log('\n\nTEST OVER!!!\n\n'); + // Set to true => true + config.setConfig({ + rubicon: { + netRevenue: true + } + }); + bids = spec.interpretResponse({body: response}, { + bidRequest: bidderRequest.bids[0] + }); + expect(bids).to.be.lengthOf(2); + expect(bids[0].netRevenue).to.equal(true); + expect(bids[1].netRevenue).to.equal(true); + + // Set to undefined => true + config.setConfig({ + rubicon: { + netRevenue: undefined + } + }); + bids = spec.interpretResponse({body: response}, { + bidRequest: bidderRequest.bids[0] + }); + expect(bids).to.be.lengthOf(2); + expect(bids[0].netRevenue).to.equal(true); + expect(bids[1].netRevenue).to.equal(true); + + // Set to string => true + config.setConfig({ + rubicon: { + netRevenue: 'someString' + } + }); + bids = spec.interpretResponse({body: response}, { + bidRequest: bidderRequest.bids[0] + }); + expect(bids).to.be.lengthOf(2); + expect(bids[0].netRevenue).to.equal(true); + expect(bids[1].netRevenue).to.equal(true); + config.resetConfig(); }); it('should use "network-advertiser" if no creative_id', function () {