@@ -293,12 +293,41 @@ describe("Restangular", function() {
293
293
294
294
} ) ;
295
295
296
- describe ( "With Url " , function ( ) {
297
- it ( "Shouldn 't add suffix to URL " , function ( ) {
296
+ describe ( "With Suffix " , function ( ) {
297
+ it ( "shouldn 't add suffix to getRestangularUrl " , function ( ) {
298
298
var suffixRestangular = Restangular . withConfig ( function ( RestangularConfigurer ) {
299
299
RestangularConfigurer . setRequestSuffix ( '.json' ) ;
300
300
} ) ;
301
+ var collection = suffixRestangular . all ( 'accounts' ) ;
302
+ expect ( collection . getRestangularUrl ( ) ) . toBe ( '/accounts' ) ;
303
+ expect ( collection . one ( '1' ) . getRestangularUrl ( ) ) . toBe ( '/accounts/1' ) ;
304
+ } ) ;
305
+
306
+ it ( "should add suffix to getRequestedUrl" , function ( ) {
307
+ var suffixRestangular = Restangular . withConfig ( function ( RestangularConfigurer ) {
308
+ RestangularConfigurer . setRequestSuffix ( '.json' ) ;
309
+ } ) ;
310
+ var collection = suffixRestangular . all ( 'accounts' ) ;
311
+ expect ( collection . getRequestedUrl ( ) ) . toBe ( '/accounts.json' ) ;
312
+ expect ( collection . one ( '1' ) . getRequestedUrl ( ) ) . toBe ( '/accounts/1.json' ) ;
313
+ } ) ;
314
+
315
+ it ( "should add suffix to request" , function ( ) {
316
+ var suffixRestangular = Restangular . withConfig ( function ( RestangularConfigurer ) {
317
+ RestangularConfigurer . setRequestSuffix ( '.json' ) ;
318
+ } ) ;
319
+ var collection = suffixRestangular . all ( 'accounts' ) ;
320
+ $httpBackend . expectGET ( '/accounts.json' ) . respond ( 200 ) ;
321
+ $httpBackend . expectGET ( '/accounts/1.json' ) . respond ( 200 ) ;
322
+ collection . getList ( ) ;
323
+ collection . get ( '1' ) ;
324
+ $httpBackend . flush ( ) ;
325
+ } ) ;
301
326
327
+ it ( "shouldn't add suffix to allUrl" , function ( ) {
328
+ var suffixRestangular = Restangular . withConfig ( function ( RestangularConfigurer ) {
329
+ RestangularConfigurer . setRequestSuffix ( '.json' ) ;
330
+ } ) ;
302
331
$httpBackend . expectGET ( 'http://accounts.com/all' ) ;
303
332
suffixRestangular . allUrl ( 'accounts' , 'http://accounts.com/all' ) . getList ( ) ;
304
333
$httpBackend . flush ( ) ;
0 commit comments