@@ -1363,6 +1363,49 @@ describe("basic usage", function() {
1363
1363
} ) ;
1364
1364
} ) ;
1365
1365
1366
+ describe ( 'extra params' , function ( ) {
1367
+ var $http ;
1368
+ var $httpBackend ;
1369
+ var $resource ;
1370
+
1371
+ beforeEach ( module ( 'ngResource' ) ) ;
1372
+
1373
+ beforeEach ( module ( function ( $provide ) {
1374
+ $provide . decorator ( '$http' , function ( $delegate ) {
1375
+ return jasmine . createSpy ( '$http' ) . and . callFake ( $delegate ) ;
1376
+ } ) ;
1377
+ } ) ) ;
1378
+
1379
+ beforeEach ( inject ( function ( _$http_ , _$httpBackend_ , _$resource_ ) {
1380
+ $http = _$http_ ;
1381
+ $httpBackend = _$httpBackend_ ;
1382
+ $resource = _$resource_ ;
1383
+ } ) ) ;
1384
+
1385
+ afterEach ( function ( ) {
1386
+ $httpBackend . verifyNoOutstandingExpectation ( ) ;
1387
+ } ) ;
1388
+
1389
+
1390
+ it ( 'should pass extra params to `$http` as `config.params`' , function ( ) {
1391
+ $httpBackend . expectGET ( '/bar?baz=qux' ) . respond ( '{}' ) ;
1392
+
1393
+ var R = $resource ( '/:foo' ) ;
1394
+ R . get ( { foo : 'bar' , baz : 'qux' } ) ;
1395
+
1396
+ expect ( $http ) . toHaveBeenCalledWith ( jasmine . objectContaining ( { params : { baz : 'qux' } } ) ) ;
1397
+ } ) ;
1398
+
1399
+ it ( 'should pass extra params even if `Object.prototype` has properties with the same name' ,
1400
+ function ( ) {
1401
+ $httpBackend . expectGET ( '/foo?toString=bar' ) . respond ( '{}' ) ;
1402
+
1403
+ var R = $resource ( '/foo' ) ;
1404
+ R . get ( { toString : 'bar' } ) ;
1405
+ }
1406
+ ) ;
1407
+ } ) ;
1408
+
1366
1409
describe ( 'errors' , function ( ) {
1367
1410
var $httpBackend , $resource , $q ;
1368
1411
0 commit comments