@@ -19,25 +19,41 @@ vows.describe('Base model (models/model)').addBatch(
1919 ' ' : {
2020 topic : () -> getTopic ()
2121
22- ' when toJSON() is called' : {
23- topic : (instance ) -> instance .toJSON ()
22+ ' when toJSON() is called with no attributes' : {
23+ topic : (instance ) ->
24+ instance .toJSON ()
2425
2526 ' it should return an empty object ' : (jsonObject ) ->
2627 jsonObject .should .eql ({})
2728 }
2829
30+ ' when toJSON() is called with attributes' : {
31+ topic : (instance ) ->
32+ instance .attributes = { ' two' : false }
33+ instance .toJSON ()
34+
35+ ' it should return the attributes object ' : (jsonObject ) ->
36+ jsonObject .should .eql ({ ' two' : false })
37+ }
38+
2939 ' when save() is called' : {
3040 topic : (instance ) ->
41+ instance .attributes = {
42+ ' one' : true
43+ }
3144 instance .save (' testCollection' , @callback )
3245
3346 ' it should call save() on the base stored object ' : (err , attributes ) ->
3447 callCount .should .equal (1 )
3548 args .should .have .length (1 )
36-
37- ' it should pass all arguments to the base object ' : (err , attributes ) ->
49+
50+ ' it should pass model.attributes to the save() ' : (err , attributes ) ->
51+ args[0 ].should .have .length (3 )
52+ args[0 ][1 ].should .eql ({ ' one' : true })
53+
54+ ' it should pass collection and callback to base object ' : (err , attributes ) ->
3855 args[0 ].should .have .length (3 )
3956 args[0 ][0 ].should .equal (' testCollection' )
40- args[0 ][1 ].should .eql ({})
4157 args[0 ][2 ].should .equal (@callback )
4258 }
4359 }
0 commit comments