Skip to content

Commit

Permalink
Rubicon adapter: add a floor variable (prebid#964)
Browse files Browse the repository at this point in the history
* Add a floor variable

* Added floor parameter test
  • Loading branch information
benjaminclot authored and Will Alexander committed Mar 6, 2017
1 parent 63f6747 commit 7cf02e7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/adapters/rubicon.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ function RubiconAdapter() {
siteId,
zoneId,
position,
floor,
keywords,
visitor,
inventory,
Expand All @@ -185,6 +186,7 @@ function RubiconAdapter() {
} = bid.params;

// defaults
floor = (floor = parseFloat(floor)) > 0.01 ? floor : 0.01;
position = position || 'btf';

// use rubicon sizes if provided, otherwise adUnit.sizes
Expand All @@ -204,7 +206,7 @@ function RubiconAdapter() {
'size_id', parsedSizes[0],
'alt_size_ids', parsedSizes.slice(1).join(',') || undefined,
'p_pos', position,
'rp_floor', '0.01',
'rp_floor', floor,
'tk_flint', getIntegration(),
'p_screen_res', _getScreenResolution(),
'kw', keywords,
Expand Down
17 changes: 15 additions & 2 deletions test/spec/adapters/rubicon_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ describe('the rubicon adapter', () => {
expect(query['alt_size_ids']).to.equal('57,59');

});

it('should not send a request and register an error bid if no valid sizes', () => {

var sizesBidderRequest = clone(bidderRequest);
Expand All @@ -277,6 +277,19 @@ describe('the rubicon adapter', () => {
expect(bids[0].getStatusCode()).to.equal(CONSTANTS.STATUS.NO_BID);

});

it('should allow a floor override', () => {

var floorBidderRequest = clone(bidderRequest);
floorBidderRequest.bids[0].params.floor = 2;

rubiconAdapter.callBids(floorBidderRequest);

let query = parseQuery(xhr.requests[0].url.split('?')[1]);

expect(query['rp_floor']).to.equal('2');

});

});

Expand Down Expand Up @@ -658,4 +671,4 @@ describe('the rubicon adapter', () => {

function clone(obj) {
return JSON.parse(JSON.stringify(obj));
}
}

0 comments on commit 7cf02e7

Please sign in to comment.