Skip to content

Commit

Permalink
Merge pull request #1 from prebid/master
Browse files Browse the repository at this point in the history
Show warning if bidCpmAdjustment is set for AOL bidder (closes prebid#725) …
  • Loading branch information
jpteam authored Oct 26, 2016
2 parents caa5370 + 9ba0add commit a6be2a0
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/adapters/aol.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const bidmanager = require('../bidmanager.js');

const AolAdapter = function AolAdapter() {

let showCpmAdjustmentWarning = true;
const pubapiTemplate = template`${'protocol'}://${'host'}/pubapi/3.0/${'network'}/${'placement'}/${'pageid'}/${'sizeid'}/ADTECH;v=2;cmd=bid;cors=yes;alias=${'alias'}${'bidfloor'};misc=${'misc'}`;
const BIDDER_CODE = 'aol';
const SERVER_MAP = {
Expand Down Expand Up @@ -117,6 +118,18 @@ const AolAdapter = function AolAdapter() {
const pubapiUrl = _buildPubapiUrl(bid);

ajax(pubapiUrl, response => {
// needs to be here in case bidderSettings are defined after requestBids() is called
if (showCpmAdjustmentWarning &&
$$PREBID_GLOBAL$$.bidderSettings && $$PREBID_GLOBAL$$.bidderSettings.aol &&
typeof $$PREBID_GLOBAL$$.bidderSettings.aol.bidCpmAdjustment === 'function'
) {
utils.logWarn(
'bidCpmAdjustment is active for the AOL adapter. ' +
'As of Prebid 0.14, AOL can bid in net – please contact your accounts team to enable.'
);
}
showCpmAdjustmentWarning = false; // warning is shown at most once

if (!response && response.length <= 0) {
utils.logError('Empty bid response', BIDDER_CODE, bid);
_addErrorBidResponse(bid, response);
Expand Down
32 changes: 32 additions & 0 deletions test/spec/adapters/aol_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {expect} from 'chai';
import _ from 'lodash';
import * as utils from 'src/utils';
import AolAdapter from 'src/adapters/aol';
import bidmanager from 'src/bidmanager';

Expand Down Expand Up @@ -430,5 +431,36 @@ describe('AolAdapter', () => {
expect(bidResponse.cpm).to.equal('a9334987');
});
});

describe('when bidCpmAdjustment is set', () => {
let bidderSettingsBackup;
let server;

beforeEach(() => {
bidderSettingsBackup = $$PREBID_GLOBAL$$.bidderSettings;
server = sinon.fakeServer.create();
});

afterEach(() => {
$$PREBID_GLOBAL$$.bidderSettings = bidderSettingsBackup;
server.restore();
if (console.warn.restore) {
console.warn.restore();
}
});

it('should show warning in the console', function() {
sinon.spy(utils, 'logWarn');
server.respondWith(JSON.stringify(DEFAULT_PUBAPI_RESPONSE));
$$PREBID_GLOBAL$$.bidderSettings = {
aol: {
bidCpmAdjustment: function() {}
}
};
adapter.callBids(DEFAULT_BIDDER_REQUEST);
server.respond();
expect(utils.logWarn.calledOnce).to.be.true;
});
});
});
});

0 comments on commit a6be2a0

Please sign in to comment.