Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug and add tests to catch next time #5656

Merged
merged 1 commit into from
Aug 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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