@@ -123,6 +123,37 @@ test("update with custom unique_key field", function() {
123
123
server . respond ( )
124
124
} ) ;
125
125
126
+ test ( "update single resource" , 3 , function ( ) {
127
+ var User = Model ( "user" , function ( ) {
128
+ this . use ( Model . REST , "/user" , {
129
+ update_path : function ( ) {
130
+ return this . read_path ( )
131
+ }
132
+ } )
133
+ } ) ;
134
+ var user = new User ( { 'id' : 1 , email : "bob@example.com" } ) ;
135
+
136
+ this . spy ( jQuery , "ajax" )
137
+
138
+ var server = this . sandbox . useFakeServer ( )
139
+ server . respondWith ( "PUT" , "/user" , [ 200 , {
140
+ "Content-Type" : "application/json"
141
+ } , JSON . stringify ( {
142
+ id : 1 , email : "bob@example.com"
143
+ } ) ] )
144
+
145
+ user . save ( function ( success ) {
146
+ ok ( success , "save() wasn't successful" ) ;
147
+ } ) ;
148
+
149
+ ok ( jQuery . ajax . calledOnce )
150
+ deepEqual ( JSON . parse ( jQuery . ajax . getCall ( 0 ) . args [ 0 ] . data ) , {
151
+ user : { email : "bob@example.com" }
152
+ } )
153
+
154
+ server . respond ( )
155
+ } )
156
+
126
157
test ( "destroy with named params in resource path" , function ( ) {
127
158
var Post = Model ( "post" , function ( ) {
128
159
this . use ( Model . REST , "/root/:root_id/nested/:nested_id/posts" )
0 commit comments