@@ -32,4 +32,48 @@ describe('DS.hasChanges(resourceName, id)', function () {
3232
3333 assert . isTrue ( DS . hasChanges ( 'post' , 5 ) ) ;
3434 } ) ;
35+ it ( 'should return false for resources with defined methods' , function ( ) {
36+ var Person = DS . defineResource ( {
37+ name : 'person' ,
38+ methods : {
39+ fullName : function ( ) {
40+ return this . first + ' ' + this . last ;
41+ }
42+ }
43+ } ) ;
44+
45+ DS . inject ( 'person' , {
46+ first : 'John' ,
47+ last : 'Anderson' ,
48+ id : 1
49+ } ) ;
50+
51+ assert . isFalse ( DS . hasChanges ( 'person' , 1 ) ) ;
52+ } ) ;
53+ it ( 'should return false after loading relations' , function ( ) {
54+ DS . inject ( 'user' , user10 ) ;
55+
56+ $httpBackend . expectGET ( 'http://test.angular-cache.com/organization/14?userId=10' ) . respond ( 200 , organization14 ) ;
57+ $httpBackend . expectGET ( 'http://test.angular-cache.com/user/10/comment?userId=10' ) . respond ( 200 , [
58+ comment11 ,
59+ comment12 ,
60+ comment13
61+ ] ) ;
62+ $httpBackend . expectGET ( 'http://test.angular-cache.com/profile?userId=10' ) . respond ( 200 , profile15 ) ;
63+
64+ DS . loadRelations ( 'user' , 10 , [ 'comment' , 'profile' , 'organization' ] , { params : { approvedBy : 10 } } ) . then ( function ( user ) {
65+ assert . isFalse ( DS . hasChanges ( 'user' , 10 ) ) ;
66+ } , fail ) ;
67+
68+ $httpBackend . flush ( ) ;
69+
70+ // try a comment that has a belongsTo relationship to multiple users:
71+ DS . inject ( 'comment' , comment19 ) ;
72+ $httpBackend . expectGET ( 'http://test.angular-cache.com/user/20' ) . respond ( 200 , user20 ) ;
73+ $httpBackend . expectGET ( 'http://test.angular-cache.com/user/19' ) . respond ( 200 , user19 ) ;
74+ DS . loadRelations ( 'comment' , 19 , [ 'user' ] ) . then ( function ( comment ) {
75+ assert . isFalse ( DS . hasChanges ( 'comment' , 19 ) ) ;
76+ } , fail ) ;
77+ $httpBackend . flush ( ) ;
78+ } ) ;
3579} ) ;
0 commit comments