Use new ajax error handling for reshare failures
This commit is contained in:
parent
d609238ed4
commit
bc5848fe9e
2 changed files with 5 additions and 14 deletions
|
|
@ -99,11 +99,7 @@
|
||||||
Diaspora.Mobile.PostActions.toggleActive(link);
|
Diaspora.Mobile.PostActions.toggleActive(link);
|
||||||
},
|
},
|
||||||
error: function(response) {
|
error: function(response) {
|
||||||
if (response.status === 0) {
|
Diaspora.Mobile.Alert.handleAjaxError(response);
|
||||||
alert(Diaspora.I18n.t("errors.connection"));
|
|
||||||
} else {
|
|
||||||
alert(response.responseText);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
complete: function() {
|
complete: function() {
|
||||||
Diaspora.Mobile.PostActions.hideLoader(link);
|
Diaspora.Mobile.PostActions.hideLoader(link);
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,6 @@ describe("Diaspora.Mobile.PostActions", function(){
|
||||||
Diaspora.Mobile.PostActions.initialize();
|
Diaspora.Mobile.PostActions.initialize();
|
||||||
this.reshareLink = $(".stream .reshare-action");
|
this.reshareLink = $(".stream .reshare-action");
|
||||||
spyOn(window, "confirm").and.returnValue(true);
|
spyOn(window, "confirm").and.returnValue(true);
|
||||||
spyOn(window, "alert");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("always calls showLoader before sending request and hideLoader after receiving response", function(){
|
it("always calls showLoader before sending request and hideLoader after receiving response", function(){
|
||||||
|
|
@ -223,16 +222,12 @@ describe("Diaspora.Mobile.PostActions", function(){
|
||||||
expect(Diaspora.Mobile.PostActions.toggleActive).toHaveBeenCalledWith(this.reshareLink);
|
expect(Diaspora.Mobile.PostActions.toggleActive).toHaveBeenCalledWith(this.reshareLink);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("pops an alert on server errors", function() {
|
it("lets Diaspora.Mobile.Alert handle AJAX errors", function() {
|
||||||
|
spyOn(Diaspora.Mobile.Alert, "handleAjaxError");
|
||||||
this.reshareLink.click();
|
this.reshareLink.click();
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({status: 400, responseText: "reshare failed"});
|
jasmine.Ajax.requests.mostRecent().respondWith({status: 400, responseText: "reshare failed"});
|
||||||
expect(window.alert).toHaveBeenCalledWith("reshare failed");
|
expect(Diaspora.Mobile.Alert.handleAjaxError).toHaveBeenCalled();
|
||||||
});
|
expect(Diaspora.Mobile.Alert.handleAjaxError.calls.argsFor(0)[0].responseText).toBe("reshare failed");
|
||||||
|
|
||||||
it("pops an alert on network errors", function() {
|
|
||||||
this.reshareLink.click();
|
|
||||||
jasmine.Ajax.requests.mostRecent().abort();
|
|
||||||
expect(window.alert).toHaveBeenCalledWith(Diaspora.I18n.t("errors.connection"));
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue