Permalink
Browse files

Merge pull request #407 from rmurphey/show_sibling_nav_when_no_ads

verify there are ads to show before choosing to hide sibling nav
  • Loading branch information...
2 parents ec04bfb + 189c26d commit 3cd42a54e21c1575f5858459f3f2bf0c8c00ac16 @rmurphey committed Mar 22, 2012
Showing with 41 additions and 3 deletions.
  1. +4 −3 app/toura/UI.js
  2. +37 −0 spec/app/toura/ui_spec.js
View
@@ -7,6 +7,8 @@ dojo.require('toura.components.AdTag');
(function(m) {
+var appConfig = mulberry.app.Config.get('app');
+
dojo.declare('toura.UI', dojo.Stateful, {
constructor : function() {
this.body = dojo.body();
@@ -35,7 +37,8 @@ dojo.declare('toura.UI', dojo.Stateful, {
},
_setupSiblingNav : function() {
- if (!toura.features.siblingNav || toura.features.ads) { return; }
+ if (!toura.features.siblingNav) { return; }
+ if (toura.features.ads && appConfig.ads && appConfig.ads[m.Device.type]) { return; }
this.siblingNav = m.app.UI.addPersistentComponent(toura.components.SiblingNav, {}, 'first');
this.set('siblingNavVisible', false);
@@ -73,8 +76,6 @@ dojo.declare('toura.UI', dojo.Stateful, {
return;
}
- var appConfig = mulberry.app.Config.get('app');
-
if (appConfig.ads && appConfig.ads[m.Device.type]) {
dojo.addClass(b, 'has-ads');
View
@@ -94,18 +94,55 @@ describe("toura ui", function() {
});
it("should not show the sibling nav if there are ads", function() {
+ var oldConfig = mulberry.app.Config.get('app');
+
+ mulberry.app.Config.set('app', dojo.mixin(oldConfig, { ads : {
+ phone : 'phone',
+ tablet : 'tablet'
+ } }));
+
toura.features.siblingNav = true;
toura.features.ads = true;
+
var spy = spyOn(mulberry.app.UI, 'addPersistentComponent').andCallThrough();
ui = createUI();
expect(ui.siblingNav).not.toBeDefined();
expect(spy).not.toHaveBeenCalled();
+
+ mulberry.app.Config.set('app', oldConfig);
+ });
+
+ it("should show the sibling nav if there are no ads, even if toura.features.ads is true", function() {
+ var oldConfig = mulberry.app.Config.get('app');
+
+ mulberry.app.Config.set('app', dojo.mixin(oldConfig, { ads : {
+ } }));
+
+ toura.features.siblingNav = true;
+ toura.features.ads = true;
+
+ var spy = spyOn(mulberry.app.UI, 'addPersistentComponent').andCallThrough();
+
+ ui = createUI();
+
+ expect(ui.siblingNav).toBeDefined();
+ expect(spy).toHaveBeenCalled();
+
+ mulberry.app.Config.set('app', oldConfig);
});
});
describe("ad tag", function() {
+ beforeEach(function() {
+ var oldConfig = mulberry.app.Config.get('app');
+ mulberry.app.Config.set('app', dojo.mixin(oldConfig, { ads : {
+ phone : 'phone',
+ tablet : 'tablet'
+ } }));
+ });
+
it("should create the ad container if it is enabled", function() {
toura.features.ads = true;
var spy = spyOn(mulberry.app.UI, 'addPersistentComponent');

0 comments on commit 3cd42a5

Please sign in to comment.