diff options
| author | Anthony Lieuallen | 2011-03-22 13:51:48 -0400 | 
|---|---|---|
| committer | Igor Minar | 2011-03-29 00:25:22 -0700 | 
| commit | 94514a91f8e352e97c5eb44cdace29643e57f9d6 (patch) | |
| tree | 4e78d1258b2adbddc5ee9e43d1a39ea63d35fdf3 /test/ResourceSpec.js | |
| parent | 4da65d0e8c6a3bfbe5b2c4ad5708a39e750f739a (diff) | |
| download | angular.js-94514a91f8e352e97c5eb44cdace29643e57f9d6.tar.bz2 | |
Don't mutate resource if server responded with no body
If the server provides response with no body to a resource request,
resource should not mutate the resource model in the callback.
Diffstat (limited to 'test/ResourceSpec.js')
| -rw-r--r-- | test/ResourceSpec.js | 14 | 
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ResourceSpec.js b/test/ResourceSpec.js index 633fd605..df5b624f 100644 --- a/test/ResourceSpec.js +++ b/test/ResourceSpec.js @@ -177,6 +177,20 @@ describe("resource", function() {      expect(callback).wasCalledWith(cc);    }); +  it('should not mutate the resource object if response contains no body', function(){ +    var data = {id:{key:123}, number:'9876'}; +    xhr.expectGET("/CreditCard/123").respond(data); +    var cc = CreditCard.get({id:123}); +    xhr.flush(); +    expect(cc instanceof CreditCard).toBeTruthy(); +    var idBefore = cc.id; + +    xhr.expectPOST("/CreditCard/123", data).respond(''); +    cc.$save(); +    xhr.flush(); +    expect(idBefore).toEqual(cc.id); +  }); +    it('should bind default parameters', function(){      xhr.expectGET('/CreditCard/123.visa?minimum=0.05').respond({id:123});      var Visa = CreditCard.bind({verb:'.visa', minimum:0.05});  | 
