diff --git a/Changelog.md b/Changelog.md index 4d41f1dcded8e8713361ba93d2e6bea93b3c96af..c61a5d91e9d17c34591d68234551175c1dacc7b9 100644 --- a/Changelog.md +++ b/Changelog.md @@ -161,6 +161,7 @@ diaspora* no longer adds a `div.container` to wrap custom splash pages. This add * Fix displaying reshares in the stream on mobile [#5790](https://github.com/diaspora/diaspora/pull/5790) * Remove bottom margin from lists that are the last element of a post. [#5721](https://github.com/diaspora/diaspora/pull/5721) * Fix pagination design on conversations page [#5791](https://github.com/diaspora/diaspora/pull/5791) +* Prevent inserting posts into the wrong stream [#5838](https://github.com/diaspora/diaspora/pull/5838) ## Features * Don't pull jQuery from a CDN by default [#5105](https://github.com/diaspora/diaspora/pull/5105) diff --git a/app/assets/javascripts/app/models/post/interactions.js b/app/assets/javascripts/app/models/post/interactions.js index f7457a5211bdf0b379347749815aa2136a85115d..d992440f74706dde724fee665b2ae4af038591a8 100644 --- a/app/assets/javascripts/app/models/post/interactions.js +++ b/app/assets/javascripts/app/models/post/interactions.js @@ -110,7 +110,9 @@ app.models.Post.Interactions = Backbone.Model.extend({ notice: Diaspora.I18n.t("reshares.successful") }); interactions.reshares.add(reshare); - if (app.stream) {app.stream.addNow(reshare)} + if (app.stream && /^\/(?:stream|activity|aspects)/.test(app.stream.basePath())) { + app.stream.addNow(reshare); + } interactions.trigger("change"); }) .fail(function(){ diff --git a/app/assets/javascripts/app/views/publisher_view.js b/app/assets/javascripts/app/views/publisher_view.js index 6c6e8637258a28e533c2dfc811c0d09122a2edea..5a928f102b4424c95f3546e00406829448bc5b42 100644 --- a/app/assets/javascripts/app/views/publisher_view.js +++ b/app/assets/javascripts/app/views/publisher_view.js @@ -195,7 +195,9 @@ app.views.Publisher = Backbone.View.extend({ self.view_poll_creator.trigger('publisher:sync'); } - if(app.stream) app.stream.addNow(statusMessage.toJSON()); + if(app.stream && !self.standalone){ + app.stream.addNow(statusMessage.toJSON()); + } // clear state self.clear(); diff --git a/spec/javascripts/app/models/post/interacations_spec.js b/spec/javascripts/app/models/post/interacations_spec.js index c5c4ff83edb61ae6d1b31b1b2d8cf035ede3aee7..0536b3f1d85016e08a381b63461cec535a406f58 100644 --- a/spec/javascripts/app/models/post/interacations_spec.js +++ b/spec/javascripts/app/models/post/interacations_spec.js @@ -42,7 +42,7 @@ describe("app.models.Post.Interactions", function(){ }); describe("reshare", function() { - var ajax_success = { status: 200, responseText: '{"id": 1}' }; + var ajaxSuccess = { status: 200, responseText: "{\"id\": 1}" }; beforeEach(function(){ this.reshare = this.interactions.post.reshare(); @@ -52,18 +52,34 @@ describe("app.models.Post.Interactions", function(){ spyOn(this.interactions, "trigger"); this.interactions.reshare(); - jasmine.Ajax.requests.mostRecent().respondWith(ajax_success); + jasmine.Ajax.requests.mostRecent().respondWith(ajaxSuccess); expect(this.interactions.trigger).toHaveBeenCalledWith("change"); }); - it("adds the reshare to the stream", function() { + it("adds the reshare to the default, activity and aspects stream", function() { app.stream = { addNow: $.noop }; spyOn(app.stream, "addNow"); - this.interactions.reshare(); - jasmine.Ajax.requests.mostRecent().respondWith(ajax_success); + var self = this; + ["/stream", "/activity", "/aspects"].forEach(function(path) { + app.stream.basePath = function() { return path; }; + self.interactions.reshare(); + jasmine.Ajax.requests.mostRecent().respondWith(ajaxSuccess); + + expect(app.stream.addNow).toHaveBeenCalledWith({id: 1}); + }); + }); - expect(app.stream.addNow).toHaveBeenCalledWith({id: 1}); + it("doesn't add the reshare to any other stream", function() { + app.stream = { addNow: $.noop }; + spyOn(app.stream, "addNow"); + var self = this; + ["/followed_tags", "/mentions/", "/tag/diaspora", "/people/guid/stream"].forEach(function(path) { + app.stream.basePath = function() { return path; }; + self.interactions.reshare(); + jasmine.Ajax.requests.mostRecent().respondWith(ajaxSuccess); + expect(app.stream.addNow).not.toHaveBeenCalled(); + }); }); }); }); diff --git a/spec/javascripts/app/views/publisher_view_spec.js b/spec/javascripts/app/views/publisher_view_spec.js index bcb73ee13bee5d505323dfb32aabc234938afddd..8390f6b83b0e89e6523a8b4051ad578388068d59 100644 --- a/spec/javascripts/app/views/publisher_view_spec.js +++ b/spec/javascripts/app/views/publisher_view_spec.js @@ -4,7 +4,7 @@ */ describe("app.views.Publisher", function() { - describe("standalone", function() { + context("standalone", function() { beforeEach(function() { // TODO should be jasmine helper loginAs({name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}}); @@ -22,6 +22,16 @@ describe("app.views.Publisher", function() { it("hides the post preview button in standalone mode", function() { expect(this.view.$('.post_preview_button').is(':visible')).toBeFalsy(); }); + + describe("createStatusMessage", function(){ + it("doesn't add the status message to the stream", function() { + app.stream = { addNow: $.noop }; + spyOn(app.stream, "addNow"); + this.view.createStatusMessage($.Event()); + jasmine.Ajax.requests.mostRecent().respondWith({ status: 200, responseText: "{\"id\": 1}" }); + expect(app.stream.addNow).not.toHaveBeenCalled(); + }); + }); }); context("plain publisher", function() { @@ -128,6 +138,14 @@ describe("app.views.Publisher", function() { this.view.createStatusMessage($.Event()); expect(this.view.handleTextchange).toHaveBeenCalled(); }); + + it("adds the status message to the stream", function() { + app.stream = { addNow: $.noop }; + spyOn(app.stream, "addNow"); + this.view.createStatusMessage($.Event()); + jasmine.Ajax.requests.mostRecent().respondWith({ status: 200, responseText: "{\"id\": 1}" }); + expect(app.stream.addNow).toHaveBeenCalled(); + }); }); describe('#setText', function() {