Loading Changelog.md +1 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,7 @@ Contributions are very welcome, the hard work is done! * Replace mobile background with color [#6415](https://github.com/diaspora/diaspora/pull/6415) * Port flash messages to backbone [#6395](https://github.com/diaspora/diaspora/6395) * Change login/registration/forgot password button color [#6504](https://github.com/diaspora/diaspora/pull/6504) * A note regarding ignoring users was added to the failure messages on commenting/liking [#6646](https://github.com/diaspora/diaspora/pull/6646) ## Bug fixes * Destroy Participation when removing interactions with a post [#5852](https://github.com/diaspora/diaspora/pull/5852) Loading app/assets/javascripts/app/models/post/interactions.js +11 −6 Original line number Diff line number Diff line Loading @@ -45,7 +45,7 @@ app.models.Post.Interactions = Backbone.Model.extend({ userLike : function(){ return this.likes.select(function(like){ return like.get("author").guid === app.currentUser.get("guid"); return like.get("author") && like.get("author").guid === app.currentUser.get("guid"); })[0]; }, Loading @@ -65,10 +65,15 @@ app.models.Post.Interactions = Backbone.Model.extend({ like : function() { var self = this; this.likes.create({}, {success : function(){ this.likes.create({}, { success: function() { self.trigger("change"); self.set({"likes_count" : self.get("likes_count") + 1}); }}); }, error: function() { app.flashMessages.error(Diaspora.I18n.t("failed_to_like")); } }); app.instrument("track", "Like"); }, Loading @@ -87,7 +92,7 @@ app.models.Post.Interactions = Backbone.Model.extend({ var self = this; this.comments.make(text).fail(function () { app.flashMessages.error(Diaspora.I18n.t("failed_to_post_message")); app.flashMessages.error(Diaspora.I18n.t("failed_to_comment")); }).done(function() { self.trigger('change'); //updates after sync }); Loading config/locales/javascript/javascript.en.yml +2 −1 Original line number Diff line number Diff line Loading @@ -150,8 +150,9 @@ en: one: "In <%= count %> aspect" other: "In <%= count %> aspects" show_more: "Show more" failed_to_like: "Failed to like!" failed_to_like: "Failed to like. Maybe the author is ignoring you?" failed_to_reshare: "Failed to reshare!" failed_to_comment: "Failed to comment. Maybe the author is ignoring you?" failed_to_post_message: "Failed to post message!" failed_to_remove: "Failed to remove the entry!" comments: Loading spec/javascripts/app/models/post/interacations_spec.js +87 −0 Original line number Diff line number Diff line Loading @@ -82,4 +82,91 @@ describe("app.models.Post.Interactions", function(){ }); }); }); describe("userLike", function(){ beforeEach(function() { this.interactions.likes.reset([]); }); it("returns false if no user liked the post", function() { expect(this.interactions.userLike()).toBeFalsy(); }); it("returns true if only the current user liked the post", function() { this.interactions.likes.add(this.userLike); expect(this.interactions.userLike()).toBeTruthy(); }); it("returns false if only another user liked the post", function() { var anotherAuthor = factory.author({guid: "anotherAuthor"}); var anotherLike = new app.models.Like({author : anotherAuthor}); this.interactions.likes.add(anotherLike); expect(this.interactions.userLike()).toBeFalsy(); }); it("returns true if the current user and another user liked the post", function() { var anotherAuthor = factory.author({guid: "anotherAuthor"}); var anotherLike = new app.models.Like({author : anotherAuthor}); this.interactions.likes.add(anotherLike); this.interactions.likes.add(this.userLike); expect(this.interactions.userLike()).toBeTruthy(); }); it("returns false if only a broken like exists", function() { var brokenLike = new app.models.Like(); this.interactions.likes.add(brokenLike); expect(this.interactions.userLike()).toBeFalsy(); }); it("returns true if the current user liked the post and there is a broken like", function() { var brokenLike = new app.models.Like(); this.interactions.likes.add(brokenLike); this.interactions.likes.add(this.userLike); expect(this.interactions.userLike()).toBeTruthy(); }); }); describe("userReshare", function(){ beforeEach(function() { this.interactions.reshares.reset([]); this.userReshare = new app.models.Reshare({author : this.author}); }); it("returns false if no user reshared the post", function() { expect(this.interactions.userReshare()).toBeFalsy(); }); it("returns true if only the current user reshared the post", function() { this.interactions.reshares.add(this.userReshare); expect(this.interactions.userReshare()).toBeTruthy(); }); it("returns false if only another user reshared the post", function() { var anotherAuthor = factory.author({guid: "anotherAuthor"}); var anotherReshare = new app.models.Reshare({author : anotherAuthor}); this.interactions.reshares.add(anotherReshare); expect(this.interactions.userReshare()).toBeFalsy(); }); it("returns true if the current user and another user reshared the post", function() { var anotherAuthor = factory.author({guid: "anotherAuthor"}); var anotherReshare = new app.models.Reshare({author : anotherAuthor}); this.interactions.reshares.add(anotherReshare); this.interactions.reshares.add(this.userReshare); expect(this.interactions.userReshare()).toBeTruthy(); }); it("returns false if only a broken reshare exists", function() { var brokenReshare = new app.models.Reshare(); this.interactions.reshares.add(brokenReshare); expect(this.interactions.userReshare()).toBeFalsy(); }); it("returns true if the current user reshared the post and there is a broken reshare", function() { var brokenReshare = new app.models.Reshare(); this.interactions.reshares.add(brokenReshare); this.interactions.reshares.add(this.userReshare); expect(this.interactions.userReshare()).toBeTruthy(); }); }); }); spec/javascripts/app/views/comment_stream_view_spec.js +4 −2 Original line number Diff line number Diff line Loading @@ -50,7 +50,10 @@ describe("app.views.CommentStream", function(){ }); it("doesn't add the comment to the view, when the request fails", function(){ Diaspora.I18n.load({failed_to_post_message: "posting failed!"}); // disable jshint camelcase for i18n /* jshint camelcase: false */ Diaspora.I18n.load({failed_to_comment: "posting failed!"}); /* jshint camelcase: true */ this.request.respondWith({status: 500}); expect(this.view.$(".comment-content p").text()).not.toEqual("a new comment"); Loading Loading @@ -123,5 +126,4 @@ describe("app.views.CommentStream", function(){ expect(submitCallback).toHaveBeenCalled(); }); }); }); Loading
Changelog.md +1 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,7 @@ Contributions are very welcome, the hard work is done! * Replace mobile background with color [#6415](https://github.com/diaspora/diaspora/pull/6415) * Port flash messages to backbone [#6395](https://github.com/diaspora/diaspora/6395) * Change login/registration/forgot password button color [#6504](https://github.com/diaspora/diaspora/pull/6504) * A note regarding ignoring users was added to the failure messages on commenting/liking [#6646](https://github.com/diaspora/diaspora/pull/6646) ## Bug fixes * Destroy Participation when removing interactions with a post [#5852](https://github.com/diaspora/diaspora/pull/5852) Loading
app/assets/javascripts/app/models/post/interactions.js +11 −6 Original line number Diff line number Diff line Loading @@ -45,7 +45,7 @@ app.models.Post.Interactions = Backbone.Model.extend({ userLike : function(){ return this.likes.select(function(like){ return like.get("author").guid === app.currentUser.get("guid"); return like.get("author") && like.get("author").guid === app.currentUser.get("guid"); })[0]; }, Loading @@ -65,10 +65,15 @@ app.models.Post.Interactions = Backbone.Model.extend({ like : function() { var self = this; this.likes.create({}, {success : function(){ this.likes.create({}, { success: function() { self.trigger("change"); self.set({"likes_count" : self.get("likes_count") + 1}); }}); }, error: function() { app.flashMessages.error(Diaspora.I18n.t("failed_to_like")); } }); app.instrument("track", "Like"); }, Loading @@ -87,7 +92,7 @@ app.models.Post.Interactions = Backbone.Model.extend({ var self = this; this.comments.make(text).fail(function () { app.flashMessages.error(Diaspora.I18n.t("failed_to_post_message")); app.flashMessages.error(Diaspora.I18n.t("failed_to_comment")); }).done(function() { self.trigger('change'); //updates after sync }); Loading
config/locales/javascript/javascript.en.yml +2 −1 Original line number Diff line number Diff line Loading @@ -150,8 +150,9 @@ en: one: "In <%= count %> aspect" other: "In <%= count %> aspects" show_more: "Show more" failed_to_like: "Failed to like!" failed_to_like: "Failed to like. Maybe the author is ignoring you?" failed_to_reshare: "Failed to reshare!" failed_to_comment: "Failed to comment. Maybe the author is ignoring you?" failed_to_post_message: "Failed to post message!" failed_to_remove: "Failed to remove the entry!" comments: Loading
spec/javascripts/app/models/post/interacations_spec.js +87 −0 Original line number Diff line number Diff line Loading @@ -82,4 +82,91 @@ describe("app.models.Post.Interactions", function(){ }); }); }); describe("userLike", function(){ beforeEach(function() { this.interactions.likes.reset([]); }); it("returns false if no user liked the post", function() { expect(this.interactions.userLike()).toBeFalsy(); }); it("returns true if only the current user liked the post", function() { this.interactions.likes.add(this.userLike); expect(this.interactions.userLike()).toBeTruthy(); }); it("returns false if only another user liked the post", function() { var anotherAuthor = factory.author({guid: "anotherAuthor"}); var anotherLike = new app.models.Like({author : anotherAuthor}); this.interactions.likes.add(anotherLike); expect(this.interactions.userLike()).toBeFalsy(); }); it("returns true if the current user and another user liked the post", function() { var anotherAuthor = factory.author({guid: "anotherAuthor"}); var anotherLike = new app.models.Like({author : anotherAuthor}); this.interactions.likes.add(anotherLike); this.interactions.likes.add(this.userLike); expect(this.interactions.userLike()).toBeTruthy(); }); it("returns false if only a broken like exists", function() { var brokenLike = new app.models.Like(); this.interactions.likes.add(brokenLike); expect(this.interactions.userLike()).toBeFalsy(); }); it("returns true if the current user liked the post and there is a broken like", function() { var brokenLike = new app.models.Like(); this.interactions.likes.add(brokenLike); this.interactions.likes.add(this.userLike); expect(this.interactions.userLike()).toBeTruthy(); }); }); describe("userReshare", function(){ beforeEach(function() { this.interactions.reshares.reset([]); this.userReshare = new app.models.Reshare({author : this.author}); }); it("returns false if no user reshared the post", function() { expect(this.interactions.userReshare()).toBeFalsy(); }); it("returns true if only the current user reshared the post", function() { this.interactions.reshares.add(this.userReshare); expect(this.interactions.userReshare()).toBeTruthy(); }); it("returns false if only another user reshared the post", function() { var anotherAuthor = factory.author({guid: "anotherAuthor"}); var anotherReshare = new app.models.Reshare({author : anotherAuthor}); this.interactions.reshares.add(anotherReshare); expect(this.interactions.userReshare()).toBeFalsy(); }); it("returns true if the current user and another user reshared the post", function() { var anotherAuthor = factory.author({guid: "anotherAuthor"}); var anotherReshare = new app.models.Reshare({author : anotherAuthor}); this.interactions.reshares.add(anotherReshare); this.interactions.reshares.add(this.userReshare); expect(this.interactions.userReshare()).toBeTruthy(); }); it("returns false if only a broken reshare exists", function() { var brokenReshare = new app.models.Reshare(); this.interactions.reshares.add(brokenReshare); expect(this.interactions.userReshare()).toBeFalsy(); }); it("returns true if the current user reshared the post and there is a broken reshare", function() { var brokenReshare = new app.models.Reshare(); this.interactions.reshares.add(brokenReshare); this.interactions.reshares.add(this.userReshare); expect(this.interactions.userReshare()).toBeTruthy(); }); }); });
spec/javascripts/app/views/comment_stream_view_spec.js +4 −2 Original line number Diff line number Diff line Loading @@ -50,7 +50,10 @@ describe("app.views.CommentStream", function(){ }); it("doesn't add the comment to the view, when the request fails", function(){ Diaspora.I18n.load({failed_to_post_message: "posting failed!"}); // disable jshint camelcase for i18n /* jshint camelcase: false */ Diaspora.I18n.load({failed_to_comment: "posting failed!"}); /* jshint camelcase: true */ this.request.respondWith({status: 500}); expect(this.view.$(".comment-content p").text()).not.toEqual("a new comment"); Loading Loading @@ -123,5 +126,4 @@ describe("app.views.CommentStream", function(){ expect(submitCallback).toHaveBeenCalled(); }); }); });