aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorTobias Bosch2013-11-20 16:45:39 -0800
committerTobias Bosch2013-11-21 09:51:02 -0800
commitf6ecf9a3c9090593faf5fa50586c99a56b51c776 (patch)
tree83ea6e02d5ae252c543c62a78198194c62fa2c95 /test
parenta4e6d962d78b26f5112d48c4f88c1e6234d0cae7 (diff)
downloadangular.js-f6ecf9a3c9090593faf5fa50586c99a56b51c776.tar.bz2
fix($resource): Always return a resource instance when calling class methods on resources.
Previously, calling `MyResource.save(myResourceInstance)`returned a promise, in contrast to the docs for `$resource`. However, calling `MyResource.save({name: 'Tobias"})`already correctly returned a resource instance. Fixes #4545. Closes #5061.
Diffstat (limited to 'test')
-rw-r--r--test/ngResource/resourceSpec.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ngResource/resourceSpec.js b/test/ngResource/resourceSpec.js
index 5b75c8cf..28154313 100644
--- a/test/ngResource/resourceSpec.js
+++ b/test/ngResource/resourceSpec.js
@@ -533,6 +533,18 @@ describe("resource", function() {
expect(person.name).toEqual('misko');
});
+ it('should return a resource instance when calling a class method with a resource instance', function() {
+ $httpBackend.expect('GET', '/Person/123').respond('{"name":"misko"}');
+ var Person = $resource('/Person/:id');
+ var person = Person.get({id:123});
+ $httpBackend.flush();
+ $httpBackend.expect('POST', '/Person').respond('{"name":"misko2"}');
+
+ var person2 = Person.save(person);
+ $httpBackend.flush();
+
+ expect(person2).toEqual(jasmine.any(Person));
+ });
describe('promise api', function() {