mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +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)),
|
||||
data,
|
||||
function(status, response, clear) {
|
||||
if (status == 200) {
|
||||
if (200 <= status && status < 300) {
|
||||
if (response) {
|
||||
if (action.isArray) {
|
||||
value.length = 0;
|
||||
|
|
|
|||
|
|
@ -139,13 +139,20 @@ describe("resource", function() {
|
|||
expect(log).toEqual('cb;');
|
||||
});
|
||||
|
||||
it('should delete resource', function(){
|
||||
xhr.expectDELETE("/CreditCard/123").respond({});
|
||||
it('should delete resource and call callback', function(){
|
||||
xhr.expectDELETE("/CreditCard/123").respond(200, {});
|
||||
|
||||
CreditCard.remove({id:123}, callback);
|
||||
expect(callback).wasNotCalled();
|
||||
xhr.flush();
|
||||
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(){
|
||||
|
|
|
|||
Loading…
Reference in a new issue