Increase mobile reshare counter after reshare
This commit is contained in:
parent
18256f3709
commit
bc0088eb47
2 changed files with 17 additions and 2 deletions
|
|
@ -103,6 +103,10 @@
|
||||||
},
|
},
|
||||||
success: function() {
|
success: function() {
|
||||||
Diaspora.Mobile.PostActions.toggleActive(link);
|
Diaspora.Mobile.PostActions.toggleActive(link);
|
||||||
|
var reshareCounter = $(evt.target).closest(".stream-element").find(".reshare-count");
|
||||||
|
if (reshareCounter) {
|
||||||
|
reshareCounter.text(parseInt(reshareCounter.text(), 10) + 1);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
error: function(response) {
|
error: function(response) {
|
||||||
Diaspora.Mobile.Alert.handleAjaxError(response);
|
Diaspora.Mobile.Alert.handleAjaxError(response);
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ describe("Diaspora.Mobile.PostActions", function(){
|
||||||
spec.loadFixture("aspects_index_mobile_public_post");
|
spec.loadFixture("aspects_index_mobile_public_post");
|
||||||
Diaspora.Mobile.PostActions.initialize();
|
Diaspora.Mobile.PostActions.initialize();
|
||||||
this.link = $(".stream .like-action").first();
|
this.link = $(".stream .like-action").first();
|
||||||
this.likeCounter = this.link.closest(".stream-element").find(".like-count");
|
this.likeCounter = this.link.find(".like-count");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("always calls showLoader before sending request", function(){
|
it("always calls showLoader before sending request", function(){
|
||||||
|
|
@ -143,7 +143,7 @@ describe("Diaspora.Mobile.PostActions", function(){
|
||||||
spec.loadFixture("aspects_index_mobile_public_post");
|
spec.loadFixture("aspects_index_mobile_public_post");
|
||||||
Diaspora.Mobile.PostActions.initialize();
|
Diaspora.Mobile.PostActions.initialize();
|
||||||
this.link = $(".stream .like-action").first();
|
this.link = $(".stream .like-action").first();
|
||||||
this.likeCounter = this.link.closest(".stream-element").find(".like-count");
|
this.likeCounter = this.link.find(".like-count");
|
||||||
Diaspora.Mobile.PostActions.like(this.likeCounter, this.link);
|
Diaspora.Mobile.PostActions.like(this.likeCounter, this.link);
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({status: 201, responseText: "{\"id\": \"18\"}"});
|
jasmine.Ajax.requests.mostRecent().respondWith({status: 201, responseText: "{\"id\": \"18\"}"});
|
||||||
});
|
});
|
||||||
|
|
@ -238,6 +238,17 @@ describe("Diaspora.Mobile.PostActions", function(){
|
||||||
expect(Diaspora.Mobile.PostActions.toggleActive).toHaveBeenCalledWith(this.reshareLink);
|
expect(Diaspora.Mobile.PostActions.toggleActive).toHaveBeenCalledWith(this.reshareLink);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("increases the reshare count on success", function() {
|
||||||
|
spyOn(Diaspora.Mobile.PostActions, "toggleActive");
|
||||||
|
var reshareCounter = this.reshareLink.find(".reshare-count");
|
||||||
|
reshareCounter.text("8");
|
||||||
|
|
||||||
|
this.reshareLink.click();
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith({status: 201, responseText: "{}"});
|
||||||
|
expect(Diaspora.Mobile.PostActions.toggleActive).toHaveBeenCalledWith(this.reshareLink);
|
||||||
|
expect(reshareCounter.text()).toBe("9");
|
||||||
|
});
|
||||||
|
|
||||||
it("lets Diaspora.Mobile.Alert handle AJAX errors", function() {
|
it("lets Diaspora.Mobile.Alert handle AJAX errors", function() {
|
||||||
spyOn(Diaspora.Mobile.Alert, "handleAjaxError");
|
spyOn(Diaspora.Mobile.Alert, "handleAjaxError");
|
||||||
this.reshareLink.click();
|
this.reshareLink.click();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue