mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-24 22:03:43 +00:00
correct $resource's success callback execution
succcess callbacks should be executed for status codes in the range of <200,300).
This commit is contained in:
parent
9bd2c3967b
commit
754d2541c4
2 changed files with 10 additions and 3 deletions
|
|
@ -96,7 +96,7 @@ ResourceFactory.prototype = {
|
||||||
route.url(extend({}, action.params || {}, extractParams(data), params)),
|
route.url(extend({}, action.params || {}, extractParams(data), params)),
|
||||||
data,
|
data,
|
||||||
function(status, response, clear) {
|
function(status, response, clear) {
|
||||||
if (status == 200) {
|
if (200 <= status && status < 300) {
|
||||||
if (response) {
|
if (response) {
|
||||||
if (action.isArray) {
|
if (action.isArray) {
|
||||||
value.length = 0;
|
value.length = 0;
|
||||||
|
|
|
||||||
|
|
@ -139,13 +139,20 @@ describe("resource", function() {
|
||||||
expect(log).toEqual('cb;');
|
expect(log).toEqual('cb;');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should delete resource', function(){
|
it('should delete resource and call callback', function(){
|
||||||
xhr.expectDELETE("/CreditCard/123").respond({});
|
xhr.expectDELETE("/CreditCard/123").respond(200, {});
|
||||||
|
|
||||||
CreditCard.remove({id:123}, callback);
|
CreditCard.remove({id:123}, callback);
|
||||||
expect(callback).wasNotCalled();
|
expect(callback).wasNotCalled();
|
||||||
xhr.flush();
|
xhr.flush();
|
||||||
nakedExpect(callback.mostRecentCall.args).toEqual([{}]);
|
nakedExpect(callback.mostRecentCall.args).toEqual([{}]);
|
||||||
|
|
||||||
|
callback.reset();
|
||||||
|
xhr.expectDELETE("/CreditCard/333").respond(204, null);
|
||||||
|
CreditCard.remove({id:333}, callback);
|
||||||
|
expect(callback).wasNotCalled();
|
||||||
|
xhr.flush();
|
||||||
|
nakedExpect(callback.mostRecentCall.args).toEqual([{}]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should post charge verb', function(){
|
it('should post charge verb', function(){
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue