From ce44a00c58cc1c09d75c6b2c3a5bb1d6343d7557 Mon Sep 17 00:00:00 2001 From: Steffen van Bergerem Date: Wed, 3 May 2017 11:54:35 +0200 Subject: [PATCH] Fix first comment in mobile view with french locale Fixes #7438. The regression has possibly been introduced by #7207. closes #7441 --- Changelog.md | 1 + app/assets/javascripts/mobile/mobile_comments.js | 2 +- spec/javascripts/mobile/mobile_comments_spec.js | 14 +++++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index 4fd01ec8e50..1ca3a9d6ee8 100644 --- a/Changelog.md +++ b/Changelog.md @@ -24,6 +24,7 @@ ## Bug fixes * Make photo upload button hover text translatable [#7429](https://github.com/diaspora/diaspora/pull/7429) +* Fix first comment in mobile view with french locale [#7441](https://github.com/diaspora/diaspora/pull/7441) ## Features diff --git a/app/assets/javascripts/mobile/mobile_comments.js b/app/assets/javascripts/mobile/mobile_comments.js index 0861ec0f26a..49858bc1c08 100644 --- a/app/assets/javascripts/mobile/mobile_comments.js +++ b/app/assets/javascripts/mobile/mobile_comments.js @@ -201,7 +201,7 @@ increaseReactionCount: function(bottomBar) { var toggleReactionsLink = bottomBar.find(".show-comments").first(); var count = toggleReactionsLink.text().match(/.*(\d+).*/); - count = parseInt(count, 10); + count = parseInt(count, 10) || 0; var text = Diaspora.I18n.t("stream.comments", {count: count + 1}); // No previous comment diff --git a/spec/javascripts/mobile/mobile_comments_spec.js b/spec/javascripts/mobile/mobile_comments_spec.js index 7a751443f74..e87a81adcb1 100644 --- a/spec/javascripts/mobile/mobile_comments_spec.js +++ b/spec/javascripts/mobile/mobile_comments_spec.js @@ -144,7 +144,7 @@ describe("Diaspora.Mobile.Comments", function(){ expect(this.toggleReactionsLink.text().trim()).toBe("6 comments"); }); - it("Creates the reaction link when no reactions", function(){ + it("Creates the reaction link when there are no reactions", function() { var parent = this.toggleReactionsLink.parent(); var postGuid = this.bottomBar.parents(".stream-element").data("guid"); this.toggleReactionsLink.remove(); @@ -155,6 +155,18 @@ describe("Diaspora.Mobile.Comments", function(){ expect(this.toggleReactionsLink.text().trim()).toBe("1 comment"); expect(this.toggleReactionsLink.attr("href")).toBe("/posts/" + postGuid + "/comments.mobile"); }); + + it("Creates the reaction link when there are no reactions (french locale)", function() { + var parent = this.toggleReactionsLink.parent(); + var postGuid = this.bottomBar.parents(".stream-element").data("guid"); + this.toggleReactionsLink.remove(); + parent.prepend($("", {"class": "show-comments"}).text("Aucun commentaire")); + + Diaspora.Mobile.Comments.increaseReactionCount(this.bottomBar); + this.toggleReactionsLink = this.bottomBar.find(".show-comments").first(); + expect(this.toggleReactionsLink.text().trim()).toBe("1 comment"); + expect(this.toggleReactionsLink.attr("href")).toBe("/posts/" + postGuid + "/comments.mobile"); + }); }); describe("bottomBarLazy", function(){