@@ -84,6 +84,25 @@ describe('DS.findAll(resourceName, params[, options]): ', function () {
8484 assert . equal ( lifecycle . serialize . callCount , 0 , 'serialize should have been called' ) ;
8585 assert . equal ( lifecycle . deserialize . callCount , 2 , 'deserialize should have been called' ) ;
8686 } ) ;
87+ it ( 'should fail when no "idAttribute" is present on an item in the response' , function ( ) {
88+ $httpBackend . expectGET ( / h t t p : \/ \/ t e s t \. a n g u l a r - c a c h e \. c o m \/ p o s t s \? ? / ) . respond ( 200 , [
89+ { author : 'John' , age : 30 } ,
90+ { author : 'Sally' , age : 31 }
91+ ] ) ;
92+
93+ DS . findAll ( 'post' , { } ) . then ( function ( ) {
94+ fail ( 'Should not have succeeded!' ) ;
95+ } , function ( err ) {
96+ assert ( err . message , 'DS.inject(resourceName, attrs[, options]): attrs: Must contain the property specified by `idAttribute`!' ) ;
97+ assert . deepEqual ( DS . filter ( 'post' , { } ) , [ ] , 'The posts should not be in the store' ) ;
98+ } ) ;
99+
100+ $httpBackend . flush ( ) ;
101+
102+ assert ( $log . error . logs [ 0 ] [ 0 ] . message , 'DS.inject(resourceName, attrs[, options]): attrs: Must contain the property specified by `idAttribute`!' ) ;
103+ assert . equal ( lifecycle . beforeInject . callCount , 0 , 'beforeInject should not have been called' ) ;
104+ assert . equal ( lifecycle . afterInject . callCount , 0 , 'afterInject should not have been called' ) ;
105+ } ) ;
87106 it ( 'should query the server for a collection but not store the data if cacheResponse is false' , function ( ) {
88107 $httpBackend . expectGET ( / h t t p : \/ \/ t e s t \. a n g u l a r - c a c h e \. c o m \/ p o s t s \? ? / ) . respond ( 200 , [ p1 , p2 , p3 , p4 ] ) ;
89108
0 commit comments