Skip to content
Extraits de code Groupes Projets
Valider 3a0857b4 rédigé par Jonne Haß's avatar Jonne Haß
Parcourir les fichiers

Merge pull request #5699 from WebDevFromScratch/5690-update-stream-on-reshare

5690 update stream on reshare
parents cdd1155b b8be76be
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -175,6 +175,7 @@ diaspora.yml file**. The existing settings from 0.4.x and before will not work a
* Add invitation link to contacts page [#5655](https://github.com/diaspora/diaspora/pull/5655)
* Add year to notifications page [#5676](https://github.com/diaspora/diaspora/pull/5676)
* Give admins the ability to lock & unlock accounts [#5643](https://github.com/diaspora/diaspora/pull/5643)
* Add reshares to the stream view immediately [#5699](https://github.com/diaspora/diaspora/pull/5699)
# 0.4.1.2
......
......@@ -103,23 +103,21 @@ app.models.Post.Interactions = Backbone.Model.extend({
, reshare = this.post.reshare()
, flash = new Diaspora.Widgets.FlashMessages();
reshare.save({}, {
success : function(){
reshare.save()
.done(function(){
flash.render({
success: true,
notice: Diaspora.I18n.t("reshares.successful")
});
},
error: function(){
interactions.reshares.add(reshare);
if (app.stream) {app.stream.addNow(reshare)}
interactions.trigger("change");
})
.fail(function(){
flash.render({
success: false,
notice: Diaspora.I18n.t("reshares.duplicate")
});
}
}).done(function(){
interactions.reshares.add(reshare);
}).done(function(){
interactions.trigger("change");
});
app.instrument("track", "Reshare");
......
......@@ -40,4 +40,30 @@ describe("app.models.Post.Interactions", function(){
expect(this.interactions.likes.length).toEqual(0);
});
});
describe("reshare", function() {
var ajax_success = { status: 200, responseText: [] };
beforeEach(function(){
this.reshare = this.interactions.post.reshare();
});
it("triggers a change on the model", function() {
spyOn(this.interactions, "trigger");
this.interactions.reshare();
jasmine.Ajax.requests.mostRecent().respondWith(ajax_success);
expect(this.interactions.trigger).toHaveBeenCalledWith("change");
});
it("adds the reshare to the stream", function() {
app.stream = { addNow: $.noop };
spyOn(app.stream, "addNow");
this.interactions.reshare();
jasmine.Ajax.requests.mostRecent().respondWith(ajax_success);
expect(app.stream.addNow).toHaveBeenCalledWith(this.reshare);
});
});
});
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter