Don't add mentions and reshares to all streams
This commit is contained in:
parent
5dd5f0b176
commit
1701bc30d0
4 changed files with 47 additions and 9 deletions
|
|
@ -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(){
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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});
|
||||
});
|
||||
});
|
||||
|
||||
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();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue