changed reshare function, so it adds the object to the stream
tests for reshares Changelog.md update fixing a style issue removed unnecessary semicolon
This commit is contained in:
parent
cdd1155bd2
commit
b8be76be3c
3 changed files with 34 additions and 9 deletions
|
|
@ -135,6 +135,7 @@ diaspora.yml file**. The existing settings from 0.4.x and before will not work a
|
||||||
* Fix code overflow for the mobile website [#5675](https://github.com/diaspora/diaspora/pull/5675)
|
* Fix code overflow for the mobile website [#5675](https://github.com/diaspora/diaspora/pull/5675)
|
||||||
* Strip Unicode format characters prior post processing [#5680](https://github.com/diaspora/diaspora/pull/5680)
|
* Strip Unicode format characters prior post processing [#5680](https://github.com/diaspora/diaspora/pull/5680)
|
||||||
* Disable email notifications for closed user accounts [#5640](https://github.com/diaspora/diaspora/pull/5640)
|
* Disable email notifications for closed user accounts [#5640](https://github.com/diaspora/diaspora/pull/5640)
|
||||||
|
* Add reshares to the stream view immediately
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
* Don't pull jQuery from a CDN by default [#5105](https://github.com/diaspora/diaspora/pull/5105)
|
* Don't pull jQuery from a CDN by default [#5105](https://github.com/diaspora/diaspora/pull/5105)
|
||||||
|
|
|
||||||
|
|
@ -103,23 +103,21 @@ app.models.Post.Interactions = Backbone.Model.extend({
|
||||||
, reshare = this.post.reshare()
|
, reshare = this.post.reshare()
|
||||||
, flash = new Diaspora.Widgets.FlashMessages();
|
, flash = new Diaspora.Widgets.FlashMessages();
|
||||||
|
|
||||||
reshare.save({}, {
|
reshare.save()
|
||||||
success : function(){
|
.done(function(){
|
||||||
flash.render({
|
flash.render({
|
||||||
success: true,
|
success: true,
|
||||||
notice: Diaspora.I18n.t("reshares.successful")
|
notice: Diaspora.I18n.t("reshares.successful")
|
||||||
});
|
});
|
||||||
},
|
interactions.reshares.add(reshare);
|
||||||
error: function(){
|
if (app.stream) {app.stream.addNow(reshare)}
|
||||||
|
interactions.trigger("change");
|
||||||
|
})
|
||||||
|
.fail(function(){
|
||||||
flash.render({
|
flash.render({
|
||||||
success: false,
|
success: false,
|
||||||
notice: Diaspora.I18n.t("reshares.duplicate")
|
notice: Diaspora.I18n.t("reshares.duplicate")
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}).done(function(){
|
|
||||||
interactions.reshares.add(reshare);
|
|
||||||
}).done(function(){
|
|
||||||
interactions.trigger("change");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.instrument("track", "Reshare");
|
app.instrument("track", "Reshare");
|
||||||
|
|
|
||||||
|
|
@ -40,4 +40,30 @@ describe("app.models.Post.Interactions", function(){
|
||||||
expect(this.interactions.likes.length).toEqual(0);
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue