aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorpetrovalex2012-05-11 23:14:59 +0300
committerMisko Hevery2012-09-06 15:49:49 -0700
commitd2e52b2376962cf9bd029f18039140c2284c77fc (patch)
tree066342b733e277c852af7632070de270d2e64912 /test
parenta56aaa9877d90c7ea6715b4647c1b7b8c6f8e7fd (diff)
downloadangular.js-d2e52b2376962cf9bd029f18039140c2284c77fc.tar.bz2
fix($resource): ignore undefined parameters
- $resource should handle multiple params with same name - ignore slashes of undefined parameters - fix default parameters issue, mentioned in #875 Closes #875 Closes #782
Diffstat (limited to 'test')
-rw-r--r--test/ngResource/resourceSpec.js27
1 files changed, 25 insertions, 2 deletions
diff --git a/test/ngResource/resourceSpec.js b/test/ngResource/resourceSpec.js
index e6bab249..37a8d568 100644
--- a/test/ngResource/resourceSpec.js
+++ b/test/ngResource/resourceSpec.js
@@ -55,12 +55,14 @@ describe("resource", function() {
$httpBackend.expect('GET', '/Path');
$httpBackend.expect('GET', '/Path/1');
$httpBackend.expect('GET', '/Path/2/3');
- $httpBackend.expect('GET', '/Path/4/5/6');
+ $httpBackend.expect('GET', '/Path/4/5');
+ $httpBackend.expect('GET', '/Path/6/7/8');
R.get({});
R.get({a:1});
R.get({a:2, b:3});
- R.get({a:4, b:5, c:6});
+ R.get({a:4, c:5});
+ R.get({a:6, b:7, c:8});
});
@@ -123,6 +125,27 @@ describe("resource", function() {
});
+ it('should build resource with action default param reading the value from instance', function() {
+ $httpBackend.expect('POST', '/Customer/123').respond();
+ var R = $resource('/Customer/:id', {}, {post: {method: 'POST', params: {id: '@id'}}});
+
+ var inst = new R({id:123});
+ expect(inst.id).toBe(123);
+
+ inst.$post();
+ });
+
+
+ it('should handle multiple params with same name', function() {
+ var R = $resource('/:id/:id');
+
+ $httpBackend.when('GET').respond('{}');
+ $httpBackend.expect('GET', '/1/1');
+
+ R.get({id:1});
+ });
+
+
it("should create resource", function() {
$httpBackend.expect('POST', '/CreditCard', '{"name":"misko"}').respond({id: 123, name: 'misko'});