mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
fix($resource): action defaults should override resource defaults
defaults definned per action should take precedence over defaults defined for the whole resource. This is potentialy a BREAKING CHANGE in case someone relied on the buggy behavior.
This commit is contained in:
parent
62d34e1437
commit
b3ed7a8a7a
2 changed files with 10 additions and 1 deletions
|
|
@ -109,7 +109,7 @@ ResourceFactory.prototype = {
|
|||
var value = this instanceof Resource ? this : (action.isArray ? [] : new Resource(data));
|
||||
self.xhr(
|
||||
action.method,
|
||||
route.url(extend({}, action.params || {}, extractParams(data), params)),
|
||||
route.url(extend({}, extractParams(data), action.params || {}, params)),
|
||||
data,
|
||||
function(status, response, responseHeaders) {
|
||||
if (response) {
|
||||
|
|
|
|||
|
|
@ -75,6 +75,15 @@ describe("resource", function() {
|
|||
nakedExpect(item).toEqual({id:'abc'});
|
||||
});
|
||||
|
||||
it("should build resource with action default param overriding default param", function(){
|
||||
xhr.expectGET('/Customer/123').respond({id:'abc'});
|
||||
var TypeItem = resource.route('/:type/:typeId', {type: 'Order'},
|
||||
{get: {method: 'GET', params: {type: 'Customer'}}});
|
||||
var item = TypeItem.get({typeId:123});
|
||||
xhr.flush();
|
||||
nakedExpect(item).toEqual({id:'abc'});
|
||||
});
|
||||
|
||||
it("should create resource", function(){
|
||||
xhr.expectPOST('/CreditCard', {name:'misko'}).respond({id:123, name:'misko'});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue