@@ -61,6 +61,21 @@ describe('manipulation', function() {
6161 Person . destroyAll ( done ) ;
6262 } ) ;
6363
64+ describe ( 'forceId' , function ( ) {
65+ before ( function ( done ) {
66+ TestForceId = db . define ( 'TestForceId' ) ;
67+ db . automigrate ( 'TestForceId' , done ) ;
68+ } ) ;
69+
70+ it ( 'it defaults to forceId:true for generated id property' , function ( done ) {
71+ TestForceId . create ( { id : 1 } , function ( err , t ) {
72+ should . exist ( err ) ;
73+ err . message . should . match ( / c a n \' t b e s e t / ) ;
74+ done ( ) ;
75+ } ) ;
76+ } ) ;
77+ } ) ;
78+
6479 it ( 'should create instance' , function ( done ) {
6580 Person . create ( { name : 'Anatoliy' } , function ( err , p ) {
6681 p . name . should . equal ( 'Anatoliy' ) ;
@@ -308,7 +323,7 @@ describe('manipulation', function() {
308323 it ( 'should refuse to create object with duplicate id' , function ( done ) {
309324 // NOTE(bajtos) We cannot reuse Person model here,
310325 // `settings.forceId` aborts the CREATE request at the validation step.
311- var Product = db . define ( 'ProductTest' , { name : String } ) ;
326+ var Product = db . define ( 'ProductTest' , { name : String } , { forceId : false } ) ;
312327 db . automigrate ( 'ProductTest' , function ( err ) {
313328 if ( err ) return done ( err ) ;
314329
@@ -825,7 +840,7 @@ describe('manipulation', function() {
825840 title : { type : String , length : 255 , index : true } ,
826841 content : { type : String } ,
827842 comments : [ String ] ,
828- } ) ;
843+ } , { forceId : false } ) ;
829844 ds . automigrate ( 'Post' , done ) ;
830845 } ) ;
831846
@@ -1046,6 +1061,8 @@ describe('manipulation', function() {
10461061 ds . automigrate ( 'Post' , done ) ;
10471062 } ) ;
10481063 beforeEach ( function ( done ) {
1064+ // TODO(bajtos) add API to lib/observer - remove observers for all hooks
1065+ Post . _observers = { } ;
10491066 Post . destroyAll ( function ( ) {
10501067 Post . create ( { title : 'a' , content : 'AAA' } , function ( err , p ) {
10511068 if ( err ) return done ( err ) ;
0 commit comments