Skip to content

Commit

Permalink
rubicon adapter - make sure creativeId is not empty (prebid#3082)
Browse files Browse the repository at this point in the history
  • Loading branch information
harpere authored Sep 12, 2018
1 parent 004256f commit b3f8788
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ export const spec = {
let bid = {
requestId: associatedBidRequest.bidId,
currency: 'USD',
creativeId: ad.creative_id,
creativeId: ad.creative_id || `${ad.network || ''}-${ad.advertiser || ''}`,
cpm: ad.cpm || 0,
dealId: ad.deal,
ttl: 300, // 5 minutes
Expand Down
123 changes: 123 additions & 0 deletions test/spec/modules/rubiconBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1553,6 +1553,129 @@ describe('the rubicon adapter', function () {
expect(bids[1].rubiconTargeting.rpfl_14062).to.equal('15_tier_all_test');
});

it('should use "network-advertiser" if no creative_id', function () {
let response = {
'status': 'ok',
'account_id': 14062,
'site_id': 70608,
'zone_id': 530022,
'size_id': 15,
'alt_size_ids': [
43, 10, 2
],
'tracking': '',
'inventory': {}
};

response.ads = [
{
'status': 'ok',
'impression_id': '153dc240-8229-4604-b8f5-256933b9374c',
'size_id': '15',
'ad_id': '6',
'advertiser': 7,
'network': 8,
'type': 'script',
'script': 'alert(\'foo\')',
'campaign_id': 10,
'cpm': 0.811,
'targeting': [
{
'key': 'rpfl_14062',
'values': [
'15_tier_all_test'
]
}
]
}
];

let bids = spec.interpretResponse({body: response}, {
bidRequest: bidderRequest.bids[0]
});
expect(bids[0].creativeId).to.equal('8-7');

response.ads = [
{
'status': 'ok',
'impression_id': '153dc240-8229-4604-b8f5-256933b9374d',
'size_id': '43',
'ad_id': '7',
'type': 'script',
'script': 'alert(\'foo\')',
'campaign_id': 10,
'cpm': 0.911,
'targeting': [
{
'key': 'rpfl_14062',
'values': [
'43_tier_all_test'
]
}
]
}
];

bids = spec.interpretResponse({body: response}, {
bidRequest: bidderRequest.bids[0]
});
expect(bids[0].creativeId).to.equal('-');

response.ads = [
{
'status': 'ok',
'impression_id': '153dc240-8229-4604-b8f5-256933b9374d',
'size_id': '10',
'ad_id': '7',
'network': 8,
'type': 'script',
'script': 'alert(\'foo\')',
'campaign_id': 10,
'cpm': 0.911,
'targeting': [
{
'key': 'rpfl_14062',
'values': [
'10_tier_all_test'
]
}
]
}
];

bids = spec.interpretResponse({body: response}, {
bidRequest: bidderRequest.bids[0]
});
expect(bids[0].creativeId).to.equal('8-');

response.ads = [
{
'status': 'ok',
'impression_id': '153dc240-8229-4604-b8f5-256933b9374d',
'size_id': '2',
'ad_id': '7',
'advertiser': 7,
'type': 'script',
'script': 'alert(\'foo\')',
'campaign_id': 10,
'cpm': 0.911,
'targeting': [
{
'key': 'rpfl_14062',
'values': [
'2_tier_all_test'
]
}
]
}
];

bids = spec.interpretResponse({body: response}, {
bidRequest: bidderRequest.bids[0]
});
expect(bids[0].creativeId).to.equal('-7');
});

it('should be fine with a CPM of 0', function () {
let response = {
'status': 'ok',
Expand Down

0 comments on commit b3f8788

Please sign in to comment.