diff options
| author | Adrian Gheorghe | 2012-09-23 01:53:08 +0200 | 
|---|---|---|
| committer | Igor Minar | 2012-11-24 21:29:16 +0100 | 
| commit | c0de8fb737d5d381e1ca5efc58c9ce5fcd860dd9 (patch) | |
| tree | adefc44624fe3de130d31053f9e415b6b39941fb /test/ngResource/resourceSpec.js | |
| parent | 557e3894d79c2542d223168b00d11edc52d4a880 (diff) | |
| download | angular.js-c0de8fb737d5d381e1ca5efc58c9ce5fcd860dd9.tar.bz2 | |
fix($resource): prevent default params to be shared between actions
Having a $resource defined as:
var R = $resource('/Path', {}, {
  get: {method: 'GET', params: {objId: '1'}},
  perform: {method: 'GET'}
});
was causing both actions to call the same URI (if called in this order):
R.get({}); // => /Path?objId=1
R.perform({}); // => /Path?objId=1
Diffstat (limited to 'test/ngResource/resourceSpec.js')
| -rw-r--r-- | test/ngResource/resourceSpec.js | 11 | 
1 files changed, 11 insertions, 0 deletions
diff --git a/test/ngResource/resourceSpec.js b/test/ngResource/resourceSpec.js index 3c14a87a..dfe98ed2 100644 --- a/test/ngResource/resourceSpec.js +++ b/test/ngResource/resourceSpec.js @@ -115,6 +115,17 @@ describe("resource", function() {    }); +  it('should not pass default params between actions', function() { +    var R = $resource('/Path', {}, {get: {method: 'GET', params: {objId: '1'}}, perform: {method: 'GET'}}); + +    $httpBackend.expect('GET', '/Path?objId=1').respond('{}'); +    $httpBackend.expect('GET', '/Path').respond('{}'); + +    R.get({}); +    R.perform({}); +  }); + +    it("should build resource with action default param overriding default param", function() {      $httpBackend.expect('GET', '/Customer/123').respond({id: 'abc'});      var TypeItem = $resource('/:type/:typeId', {type: 'Order'},  | 
