Skip to content

Commit

Permalink
Fix bug and add tests to catch next time (#5656)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertrmartinez authored Aug 24, 2020
1 parent b26bfe3 commit 01f4b28
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
4 changes: 2 additions & 2 deletions modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,8 @@ export const spec = {
try {
floorInfo = bidRequest.getFloor({
currency: 'USD',
mediaType: 'video',
size: parseSizes(bidRequest, 'video')
mediaType: 'banner',
size: '*'
});
} catch (e) {
utils.logError('Rubicon: getFloor threw an error: ', e);
Expand Down
23 changes: 22 additions & 1 deletion test/spec/modules/rubiconBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {expect} from 'chai';
import adapterManager from 'src/adapterManager.js';
import {spec, getPriceGranularity, masSizeOrdering, resetUserSync, hasVideoMediaType, FASTLANE_ENDPOINT} from 'modules/rubiconBidAdapter.js';
import {parse as parseQuery} from 'querystring';
import {config} from 'src/config.js';
Expand Down Expand Up @@ -419,7 +418,18 @@ describe('the rubicon adapter', function () {
it('should correctly send hard floors when getFloor function is present and returns valid floor', function () {
// default getFloor response is empty object so should not break and not send hard_floor
bidderRequest.bids[0].getFloor = () => getFloorResponse;
sinon.spy(bidderRequest.bids[0], 'getFloor');
let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);

// make sure banner bid called with right stuff
expect(
bidderRequest.bids[0].getFloor.calledWith({
currency: 'USD',
mediaType: 'banner',
size: '*'
})
).to.be.true;

let data = parseQuery(request.data);
expect(data.rp_hard_floor).to.be.undefined;

Expand Down Expand Up @@ -1597,12 +1607,23 @@ describe('the rubicon adapter', function () {
createVideoBidderRequest();
// default getFloor response is empty object so should not break and not send hard_floor
bidderRequest.bids[0].getFloor = () => getFloorResponse;
sinon.spy(bidderRequest.bids[0], 'getFloor');

sandbox.stub(Date, 'now').callsFake(() =>
bidderRequest.auctionStart + 100
);

let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);

// make sure banner bid called with right stuff
expect(
bidderRequest.bids[0].getFloor.calledWith({
currency: 'USD',
mediaType: 'video',
size: [640, 480]
})
).to.be.true;

// not an object should work and not send
expect(request.data.imp[0].bidfloor).to.be.undefined;

Expand Down

0 comments on commit 01f4b28

Please sign in to comment.