diff --git a/app/assets/javascripts/app/router.js b/app/assets/javascripts/app/router.js index 52117d495..312afbdae 100644 --- a/app/assets/javascripts/app/router.js +++ b/app/assets/javascripts/app/router.js @@ -180,8 +180,10 @@ app.Router = Backbone.Router.extend({ } app.page = new app.views.Stream({model : app.stream}); - app.publisher = app.publisher || new app.views.Publisher({collection : app.stream.items}); app.shortcuts = app.shortcuts || new app.views.StreamShortcuts({el: $(document)}); + if($("#publisher").length !== 0){ + app.publisher = app.publisher || new app.views.Publisher({collection : app.stream.items}); + } $("#main_stream").html(app.page.render().el); this._hideInactiveStreamLists(); diff --git a/app/assets/javascripts/app/views/tags_view.js b/app/assets/javascripts/app/views/tags_view.js index e420281fb..563050b3c 100644 --- a/app/assets/javascripts/app/views/tags_view.js +++ b/app/assets/javascripts/app/views/tags_view.js @@ -2,7 +2,9 @@ app.views.Tags = Backbone.View.extend({ initialize: function(opts) { - app.publisher.setText("#"+ opts.hashtagName + " "); + if(app.publisher){ + app.publisher.setText("#"+ opts.hashtagName + " "); + } } }); // @license-end diff --git a/spec/javascripts/app/router_spec.js b/spec/javascripts/app/router_spec.js index 0dbe5b269..a356bedb5 100644 --- a/spec/javascripts/app/router_spec.js +++ b/spec/javascripts/app/router_spec.js @@ -2,6 +2,7 @@ describe('app.Router', function () { describe('followed_tags', function() { beforeEach(function() { factory.preloads({tagFollowings: []}); + spec.loadFixture("aspects_index"); }); it('decodes name before passing it into TagFollowingAction', function () { @@ -92,6 +93,7 @@ describe('app.Router', function () { delete app.page; delete app.publisher; delete app.shortcuts; + spec.loadFixture("aspects_index"); }); it("sets app.page", function() { @@ -112,6 +114,12 @@ describe('app.Router', function () { expect(app.publisher.jasmineTestValue).toEqual(42); }); + it("doesn't set app.publisher if there is no publisher element in page", function(){ + $("#publisher").remove(); + app.router._initializeStreamView(); + expect(app.publisher).toBeUndefined(); + }); + it("sets app.shortcuts", function() { expect(app.shortcuts).toBeUndefined(); app.router._initializeStreamView();