Skip to content

Commit

Permalink
update rubicon video position default value for legacy version (#2307)
Browse files Browse the repository at this point in the history
  • Loading branch information
moonshells authored and idettman committed Apr 4, 2018
1 parent 85b4529 commit 410eacc
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 16 deletions.
2 changes: 1 addition & 1 deletion modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const spec = {
let slotData = {
site_id: params.siteId,
zone_id: params.zoneId,
position: params.position || 'btf',
position: params.position === 'atf' || params.position === 'btf' ? params.position : 'unknown',
floor: parseFloat(params.floor) > 0.01 ? params.floor : 0.01,
element_id: bidRequest.adUnitCode,
name: bidRequest.adUnitCode,
Expand Down
77 changes: 62 additions & 15 deletions test/spec/modules/rubiconBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { expect } from 'chai';
import {expect} from 'chai';
import adapterManager from 'src/adaptermanager';
import { spec, masSizeOrdering, resetUserSync } from 'modules/rubiconBidAdapter';
import { parse as parseQuery } from 'querystring';
import { newBidder } from 'src/adapters/bidderFactory';
import { userSync } from 'src/userSync';
import { config } from 'src/config';
import {spec, masSizeOrdering, resetUserSync} from 'modules/rubiconBidAdapter';
import {parse as parseQuery} from 'querystring';
import {newBidder} from 'src/adapters/bidderFactory';
import {userSync} from 'src/userSync';
import {config} from 'src/config';

var CONSTANTS = require('src/constants.json');

Expand Down Expand Up @@ -283,7 +283,8 @@ describe('the rubicon adapter', () => {

it('should send digitrust params', () => {
window.DigiTrust = {
getUser: function() {}
getUser: function () {
}
};
sandbox.stub(window.DigiTrust, 'getUser', () =>
({
Expand Down Expand Up @@ -328,7 +329,8 @@ describe('the rubicon adapter', () => {

it('should not send digitrust params due to optout', () => {
window.DigiTrust = {
getUser: function() {}
getUser: function () {
}
};
sandbox.stub(window.DigiTrust, 'getUser', () =>
({
Expand Down Expand Up @@ -356,7 +358,8 @@ describe('the rubicon adapter', () => {

it('should not send digitrust params due to failure', () => {
window.DigiTrust = {
getUser: function() {}
getUser: function () {
}
};
sandbox.stub(window.DigiTrust, 'getUser', () =>
({
Expand Down Expand Up @@ -628,6 +631,50 @@ describe('the rubicon adapter', () => {
expect(slot.visitor).to.have.property('lastsearch').that.equals('iphone');
});

it('should send request with proper ad position', () => {
createVideoBidderRequest();
let positionBidderRequest = clone(bidderRequest);
positionBidderRequest.bids[0].params.position = 'atf';
let [request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest);
let post = request.data;
let slot = post.slots[0];

expect(slot.position).to.equal('atf');

positionBidderRequest = clone(bidderRequest);
positionBidderRequest.bids[0].params.position = 'btf';
[request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest);
post = request.data;
slot = post.slots[0];

expect(slot.position).to.equal('btf');

positionBidderRequest = clone(bidderRequest);
positionBidderRequest.bids[0].params.position = 'unknown';
[request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest);
post = request.data;
slot = post.slots[0];

expect(slot.position).to.equal('unknown');

positionBidderRequest = clone(bidderRequest);
positionBidderRequest.bids[0].params.position = '123';
[request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest);
post = request.data;
slot = post.slots[0];

expect(slot.position).to.equal('unknown');

positionBidderRequest = clone(bidderRequest);
delete positionBidderRequest.bids[0].params.position;
expect(positionBidderRequest.bids[0].params.position).to.equal(undefined);
[request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest);
post = request.data;
slot = post.slots[0];

expect(slot.position).to.equal('unknown');
});

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

Expand Down Expand Up @@ -823,7 +870,7 @@ describe('the rubicon adapter', () => {
]
};

let bids = spec.interpretResponse({ body: response }, {
let bids = spec.interpretResponse({body: response}, {
bidRequest: bidderRequest.bids[0]
});

Expand Down Expand Up @@ -875,7 +922,7 @@ describe('the rubicon adapter', () => {
}]
};

let bids = spec.interpretResponse({ body: response }, {
let bids = spec.interpretResponse({body: response}, {
bidRequest: bidderRequest.bids[0]
});

Expand All @@ -898,7 +945,7 @@ describe('the rubicon adapter', () => {
'ads': []
};

let bids = spec.interpretResponse({ body: response }, {
let bids = spec.interpretResponse({body: response}, {
bidRequest: bidderRequest.bids[0]
});

Expand All @@ -922,7 +969,7 @@ describe('the rubicon adapter', () => {
}]
};

let bids = spec.interpretResponse({ body: response }, {
let bids = spec.interpretResponse({body: response}, {
bidRequest: bidderRequest.bids[0]
});

Expand All @@ -932,7 +979,7 @@ describe('the rubicon adapter', () => {
it('should handle an error because of malformed json response', () => {
let response = '{test{';

let bids = spec.interpretResponse({ body: response }, {
let bids = spec.interpretResponse({body: response}, {
bidRequest: bidderRequest.bids[0]
});

Expand Down Expand Up @@ -973,7 +1020,7 @@ describe('the rubicon adapter', () => {
'account_id': 7780
};

let bids = spec.interpretResponse({ body: response }, {
let bids = spec.interpretResponse({body: response}, {
bidRequest: bidderRequest.bids[0]
});

Expand Down

0 comments on commit 410eacc

Please sign in to comment.