From 2894984f57d3c4d4802b0faef97b985784d285f0 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sat, 12 Jan 2019 20:59:16 +0100 Subject: [PATCH] Fix order of posts on tags-stream for tags including 'activity' closes #7959 --- Changelog.md | 1 + app/assets/javascripts/app/models/stream.js | 2 +- spec/javascripts/app/models/stream_spec.js | 9 ++++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index 980fb3a33..7602d6bc3 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,6 +3,7 @@ ## Refactor ## Bug fixes +* Fix incorrect post sorting on tag streams and tag searches for tags containing the word "activity" [#7422](https://github.com/diaspora/diaspora/issues/7422) ## Features diff --git a/app/assets/javascripts/app/models/stream.js b/app/assets/javascripts/app/models/stream.js index 119107144..3b12f470f 100644 --- a/app/assets/javascripts/app/models/stream.js +++ b/app/assets/javascripts/app/models/stream.js @@ -69,7 +69,7 @@ app.models.Stream = Backbone.Collection.extend({ }, sortOrder : function() { - return /activity/.test(this.basePath()) ? "interactedAt" : "createdAt"; + return /^\/activity/.test(this.basePath()) ? "interactedAt" : "createdAt"; }, /* This function is for adding a large number of posts one by one. diff --git a/spec/javascripts/app/models/stream_spec.js b/spec/javascripts/app/models/stream_spec.js index e107a0d52..bea72ea71 100644 --- a/spec/javascripts/app/models/stream_spec.js +++ b/spec/javascripts/app/models/stream_spec.js @@ -27,7 +27,7 @@ describe("app.models.Stream", function() { }); it("returns a comparator for posts that compares interacted_at and ids for the activity stream", function() { - spyOn(stream, "basePath").and.returnValue("activity"); + spyOn(stream, "basePath").and.returnValue("/activity"); this.options = stream.collectionOptions(); expect(this.options.comparator(this.post1, this.post2)).toBe(1); expect(this.options.comparator(this.post2, this.post1)).toBe(-1); @@ -37,6 +37,13 @@ describe("app.models.Stream", function() { expect(this.options.comparator(this.post4, this.post1)).toBe(1); expect(this.options.comparator(this.post1, this.post1)).toBe(0); }); + + it("returns a comparator for posts that compares created_at and ids for tags including 'activity'", function() { + spyOn(stream, "basePath").and.returnValue("/tags/foo-activity-bar"); + this.options = stream.collectionOptions(); + expect(this.options.comparator(this.post2, this.post3)).toBe(1); + expect(this.options.comparator(this.post3, this.post2)).toBe(-1); + }); }); describe("#_fetchOpts", function() {