From 26d42e9ed71092af12ea0b5be90025c7a9ffc0f4 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Fri, 3 May 2019 13:26:16 -0400 Subject: [PATCH] Fix compatibility with other js tests --- assets/javascripts/discourse/components/ad-slot.js.es6 | 9 +++++++-- assets/javascripts/discourse/components/house-ad.js.es6 | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/assets/javascripts/discourse/components/ad-slot.js.es6 b/assets/javascripts/discourse/components/ad-slot.js.es6 index 297e224..6b6aef1 100644 --- a/assets/javascripts/discourse/components/ad-slot.js.es6 +++ b/assets/javascripts/discourse/components/ad-slot.js.es6 @@ -47,8 +47,13 @@ export default Ember.Component.extend({ @computed("placement") adComponents(placement) { // Check house ads first - const houseAds = this.site.get("house_creatives"), - adsForSlot = houseAds.settings[placement.replace(/-/g, "_")]; + const houseAds = this.site.get("house_creatives"); + if (!houseAds || !houseAds.settings) { + return []; + } + + const adsForSlot = houseAds.settings[placement.replace(/-/g, "_")]; + if ( Object.keys(houseAds.creatives).length > 0 && !Ember.isBlank(adsForSlot) diff --git a/assets/javascripts/discourse/components/house-ad.js.es6 b/assets/javascripts/discourse/components/house-ad.js.es6 index 726110b..7434a3e 100644 --- a/assets/javascripts/discourse/components/house-ad.js.es6 +++ b/assets/javascripts/discourse/components/house-ad.js.es6 @@ -56,8 +56,13 @@ export default AdComponent.extend({ }, adsNamesForSlot(placement) { - const houseAds = this.site.get("house_creatives"), - adsForSlot = houseAds.settings[placement]; + const houseAds = this.site.get("house_creatives"); + + if (!houseAds || !houseAds.settings) { + return []; + } + + const adsForSlot = houseAds.settings[placement]; if ( Object.keys(houseAds.creatives).length > 0 &&