From 94e1c0391c351b6f691fad8abed2828fa20548b2 Mon Sep 17 00:00:00 2001 From: Adrian Gheorghe Date: Sun, 23 Sep 2012 01:53:08 +0200 Subject: 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 --- test/ngResource/resourceSpec.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test') diff --git a/test/ngResource/resourceSpec.js b/test/ngResource/resourceSpec.js index dc837f80..01466f1c 100644 --- a/test/ngResource/resourceSpec.js +++ b/test/ngResource/resourceSpec.js @@ -122,6 +122,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'}, -- cgit v1.2.3