From 68f7208ff5e30e1870d7234efe0316af9db6793d Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Fri, 22 May 2015 04:11:48 +0200 Subject: [PATCH] use id from preloaded gon.post to fix broken liking with guid closes #5978 --- Changelog.md | 1 + .../javascripts/app/pages/single-post-viewer.js | 4 ++-- .../javascripts/app/pages/single-post-viewer_spec.js | 12 ++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 spec/javascripts/app/pages/single-post-viewer_spec.js diff --git a/Changelog.md b/Changelog.md index caf3d940e..b9b0a6903 100644 --- a/Changelog.md +++ b/Changelog.md @@ -36,6 +36,7 @@ * Handle empty searchable in HCard gracefully [#5962](https://github.com/diaspora/diaspora/pull/5962) * Fix a freeze in new post parsing [#5965](https://github.com/diaspora/diaspora/pull/5965) * Add case insensitive unconfirmed email addresses as authentication key [#5967](https://github.com/diaspora/diaspora/pull/5967) +* Fix liking on single post views when accessed via GUID [#5978](https://github.com/diaspora/diaspora/pull/5978) ## Features * Hide post title of limited post in comment notification email [#5843](https://github.com/diaspora/diaspora/pull/5843) diff --git a/app/assets/javascripts/app/pages/single-post-viewer.js b/app/assets/javascripts/app/pages/single-post-viewer.js index c0b5f6bf9..0eb0cc0d8 100644 --- a/app/assets/javascripts/app/pages/single-post-viewer.js +++ b/app/assets/javascripts/app/pages/single-post-viewer.js @@ -8,8 +8,8 @@ app.pages.SinglePostViewer = app.views.Base.extend({ '#single-post-interactions' : 'singlePostInteractionsView' }, - initialize : function(options) { - this.model = new app.models.Post({ id : options.id }); + initialize : function() { + this.model = new app.models.Post({ id : gon.post.id }); this.model.preloadOrFetch().done(_.bind(this.initViews, this)); this.model.interactions.fetch(); //async, yo, might want to throttle this later. this.setupLightbox(); diff --git a/spec/javascripts/app/pages/single-post-viewer_spec.js b/spec/javascripts/app/pages/single-post-viewer_spec.js new file mode 100644 index 000000000..df8f9c43c --- /dev/null +++ b/spec/javascripts/app/pages/single-post-viewer_spec.js @@ -0,0 +1,12 @@ +describe("app.pages.SinglePostViewer", function(){ + beforeEach(function() { + window.gon={};gon.post = {id: 42}; + this.view = new app.pages.SinglePostViewer(); + }); + + context("#initialize", function() { + it("uses post-id from gon", function() { + expect(this.view.model.id).toBe(gon.post.id); + }); + }); +});