From 1874c377065e854dff751c358729c6811e0a2fe5 Mon Sep 17 00:00:00 2001 From: Steffen van Bergerem Date: Fri, 28 Aug 2015 15:50:33 +0200 Subject: [PATCH] Fix back-to-top backbone view closes #6360 --- Changelog.md | 2 +- app/assets/javascripts/app/app.js | 2 +- spec/javascripts/app/views/back_to_top_view_spec.js | 11 ++++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Changelog.md b/Changelog.md index 2afd96c5a..4515a2bb2 100644 --- a/Changelog.md +++ b/Changelog.md @@ -10,7 +10,7 @@ * Extract CommentService from CommentsController [#6307](https://github.com/diaspora/diaspora/pull/6307) * Extract user/profile discovery into the diaspora\_federation-rails gem [#6310](https://github.com/diaspora/diaspora/pull/6310) * Refactor PostPresenter [#6315](https://github.com/diaspora/diaspora/pull/6315) -* Convert BackToTop to a backbone view [#6279](https://github.com/diaspora/diaspora/pull/6279) +* Convert BackToTop to a backbone view [#6279](https://github.com/diaspora/diaspora/pull/6279) and [#6360](https://github.com/diaspora/diaspora/pull/6360) ## Bug fixes * Fix indentation and a link title on the default home page [#6212](https://github.com/diaspora/diaspora/pull/6212) diff --git a/app/assets/javascripts/app/app.js b/app/assets/javascripts/app/app.js index 841a0cbd2..4ff89cf3e 100644 --- a/app/assets/javascripts/app/app.js +++ b/app/assets/javascripts/app/app.js @@ -115,7 +115,7 @@ var app = { new app.views.AspectMembership({el: this}); }); app.sidebar = new app.views.Sidebar(); - app.backToTop = new app.views.BackToTop(); + app.backToTop = new app.views.BackToTop({el: $(document)}); }, /* mixpanel wrapper function */ diff --git a/spec/javascripts/app/views/back_to_top_view_spec.js b/spec/javascripts/app/views/back_to_top_view_spec.js index 8cfed5696..726c1ae1b 100644 --- a/spec/javascripts/app/views/back_to_top_view_spec.js +++ b/spec/javascripts/app/views/back_to_top_view_spec.js @@ -1,7 +1,16 @@ describe("app.views.BackToTop", function() { beforeEach(function() { spec.loadFixture("aspects_index"); - this.view = new app.views.BackToTop(); + this.view = new app.views.BackToTop({el: $(document)}); + }); + + describe("events hash", function() { + it("calls backToTop when clicking the back-to-top button", function() { + spyOn(this.view, "backToTop"); + this.view.delegateEvents(); + this.view.$("#back-to-top").click(); + expect(this.view.backToTop).toHaveBeenCalled(); + }); }); describe("backToTop", function() {