@@ -83,9 +83,10 @@ describe('manipulation', function() {
8383 it ( 'should create instance' , function ( done ) {
8484 Person . create ( { name : 'Anatoliy' } , function ( err , p ) {
8585 p . name . should . equal ( 'Anatoliy' ) ;
86- should . not . exist ( err ) ;
86+ if ( err ) return done ( err ) ;
8787 should . exist ( p ) ;
8888 Person . findById ( p . id , function ( err , person ) {
89+ if ( err ) return done ( err ) ;
8990 person . id . should . eql ( p . id ) ;
9091 person . name . should . equal ( 'Anatoliy' ) ;
9192 done ( ) ;
@@ -113,7 +114,7 @@ describe('manipulation', function() {
113114 p . name . should . equal ( 'Anatoliy' ) ;
114115 p . isNewRecord ( ) . should . be . true ;
115116 p . save ( function ( err , inst ) {
116- should . not . exist ( err ) ;
117+ if ( err ) return done ( err ) ;
117118 inst . isNewRecord ( ) . should . be . false ;
118119 inst . should . equal ( p ) ;
119120 done ( ) ;
@@ -136,6 +137,7 @@ describe('manipulation', function() {
136137
137138 it ( 'should not return instance of object' , function ( done ) {
138139 var person = Person . create ( function ( err , p ) {
140+ if ( err ) return done ( err ) ;
139141 should . exist ( p . id ) ;
140142 if ( person ) person . should . not . be . an . instanceOf ( Person ) ;
141143 done ( ) ;
@@ -209,10 +211,11 @@ describe('manipulation', function() {
209211
210212 it ( 'should create instance with blank data' , function ( done ) {
211213 Person . create ( function ( err , p ) {
212- should . not . exist ( err ) ;
214+ if ( err ) return done ( err ) ;
213215 should . exist ( p ) ;
214216 should . not . exists ( p . name ) ;
215217 Person . findById ( p . id , function ( err , person ) {
218+ if ( err ) return done ( err ) ;
216219 person . id . should . eql ( p . id ) ;
217220 should . not . exists ( person . name ) ;
218221 done ( ) ;
@@ -350,7 +353,7 @@ describe('manipulation', function() {
350353 it ( 'should save new object' , function ( done ) {
351354 var p = new Person ;
352355 p . save ( function ( err ) {
353- should . not . exist ( err ) ;
356+ if ( err ) return done ( err ) ;
354357 should . exist ( p . id ) ;
355358 done ( ) ;
356359 } ) ;
@@ -368,13 +371,13 @@ describe('manipulation', function() {
368371
369372 it ( 'should save existing object' , function ( done ) {
370373 Person . findOne ( function ( err , p ) {
371- should . not . exist ( err ) ;
374+ if ( err ) return done ( err ) ;
372375 p . name = 'Hans' ;
373376 p . save ( function ( err ) {
374- should . not . exist ( err ) ;
377+ if ( err ) return done ( err ) ;
375378 p . name . should . equal ( 'Hans' ) ;
376379 Person . findOne ( function ( err , p ) {
377- should . not . exist ( err ) ;
380+ if ( err ) return done ( err ) ;
378381 p . name . should . equal ( 'Hans' ) ;
379382 done ( ) ;
380383 } ) ;
@@ -400,7 +403,7 @@ describe('manipulation', function() {
400403
401404 it ( 'should save invalid object (skipping validation)' , function ( done ) {
402405 Person . findOne ( function ( err , p ) {
403- should . not . exist ( err ) ;
406+ if ( err ) return done ( err ) ;
404407 p . isValid = function ( done ) {
405408 process . nextTick ( done ) ;
406409 return false ;
@@ -409,7 +412,7 @@ describe('manipulation', function() {
409412 p . save ( function ( err ) {
410413 should . exist ( err ) ;
411414 p . save ( { validate : false } , function ( err ) {
412- should . not . exist ( err ) ;
415+ if ( err ) return done ( err ) ;
413416 done ( ) ;
414417 } ) ;
415418 } ) ;
@@ -441,7 +444,7 @@ describe('manipulation', function() {
441444
442445 it ( 'should save throw error on validation' , function ( ) {
443446 Person . findOne ( function ( err , p ) {
444- should . not . exist ( err ) ;
447+ if ( err ) return done ( err ) ;
445448 p . isValid = function ( cb ) {
446449 cb ( false ) ;
447450 return false ;
@@ -548,6 +551,7 @@ describe('manipulation', function() {
548551 function ( done ) {
549552 Person . definition . settings . strict = true ;
550553 Person . findById ( person . id , function ( err , p ) {
554+ if ( err ) return done ( err ) ;
551555 p . updateAttributes ( { name : 'John' , unknownVar : undefined } ,
552556 function ( err , p ) {
553557 // if uknownVar was defined, it would return validationError
@@ -566,6 +570,7 @@ describe('manipulation', function() {
566570 function ( done ) {
567571 Person . definition . settings . strict = false ;
568572 Person . findById ( person . id , function ( err , p ) {
573+ if ( err ) return done ( err ) ;
569574 p . updateAttributes ( { name : 'John' , foo : 'bar' } ,
570575 function ( err , p ) {
571576 if ( err ) return done ( err ) ;
@@ -584,6 +589,7 @@ describe('manipulation', function() {
584589 // changes to '{}' and breaks other tests
585590 Person . definition . settings . strict = true ;
586591 Person . findById ( person . id , function ( err , p ) {
592+ if ( err ) return done ( err ) ;
587593 p . updateAttributes ( { name : 'John' , foo : 'bar' } ,
588594 function ( err , p ) {
589595 should . exist ( err ) ;
@@ -604,6 +610,7 @@ describe('manipulation', function() {
604610 it ( 'should fallback to strict:true when using strict: throw' , function ( done ) {
605611 Person . definition . settings . strict = 'throw' ;
606612 Person . findById ( person . id , function ( err , p ) {
613+ if ( err ) return done ( err ) ;
607614 p . updateAttributes ( { foo : 'bar' } ,
608615 function ( err , p ) {
609616 should . exist ( err ) ;
@@ -623,6 +630,7 @@ describe('manipulation', function() {
623630 it ( 'should fallback to strict:true when using strict:validate' , function ( done ) {
624631 Person . definition . settings . strict = 'validate' ;
625632 Person . findById ( person . id , function ( err , p ) {
633+ if ( err ) return done ( err ) ;
626634 p . updateAttributes ( { foo : 'bar' } ,
627635 function ( err , p ) {
628636 should . exist ( err ) ;
@@ -1356,9 +1364,11 @@ describe('manipulation', function() {
13561364
13571365 it ( 'should destroy record' , function ( done ) {
13581366 Person . create ( function ( err , p ) {
1367+ if ( err ) return done ( err ) ;
13591368 p . destroy ( function ( err ) {
1360- should . not . exist ( err ) ;
1369+ if ( err ) return done ( err ) ;
13611370 Person . exists ( p . id , function ( err , ex ) {
1371+ if ( err ) return done ( err ) ;
13621372 ex . should . not . be . ok ;
13631373 done ( ) ;
13641374 } ) ;
@@ -1383,10 +1393,12 @@ describe('manipulation', function() {
13831393
13841394 it ( 'should destroy all records' , function ( done ) {
13851395 Person . destroyAll ( function ( err ) {
1386- should . not . exist ( err ) ;
1396+ if ( err ) return done ( err ) ;
13871397 Person . all ( function ( err , posts ) {
1398+ if ( err ) return done ( err ) ;
13881399 posts . should . have . lengthOf ( 0 ) ;
13891400 Person . count ( function ( err , count ) {
1401+ if ( err ) return done ( err ) ;
13901402 count . should . eql ( 0 ) ;
13911403 done ( ) ;
13921404 } ) ;
@@ -1525,6 +1537,7 @@ describe('manipulation', function() {
15251537
15261538 it ( 'should allow delete(id) - success' , function ( done ) {
15271539 Person . findOne ( function ( e , p ) {
1540+ if ( e ) return done ( e ) ;
15281541 p . delete ( function ( err , info ) {
15291542 if ( err ) return done ( err ) ;
15301543 info . should . have . property ( 'count' , 1 ) ;
@@ -1536,6 +1549,7 @@ describe('manipulation', function() {
15361549 it ( 'should allow delete(id) - fail' , function ( done ) {
15371550 Person . settings . strictDelete = false ;
15381551 Person . findOne ( function ( e , p ) {
1552+ if ( e ) return done ( e ) ;
15391553 p . delete ( function ( err , info ) {
15401554 if ( err ) return done ( err ) ;
15411555 info . should . have . property ( 'count' , 1 ) ;
@@ -1550,7 +1564,8 @@ describe('manipulation', function() {
15501564
15511565 it ( 'should allow delete(id) - fail with error' , function ( done ) {
15521566 Person . settings . strictDelete = true ;
1553- Person . findOne ( function ( e , u ) {
1567+ Person . findOne ( function ( err , u ) {
1568+ if ( err ) return done ( err ) ;
15541569 u . delete ( function ( err , info ) {
15551570 if ( err ) return done ( err ) ;
15561571 info . should . have . property ( 'count' , 1 ) ;
@@ -1592,10 +1607,10 @@ describe('manipulation', function() {
15921607 function ( done ) {
15931608 var now = Date . now ( ) ;
15941609
1595- var myCustomModel = CustomModel . create ( function ( err , m ) {
1610+ CustomModel . create ( function ( err , model ) {
15961611 should . not . exists ( err ) ;
1597- m . createdAt . should . be . instanceOf ( Date ) ;
1598- ( m . createdAt >= now ) . should . be . true ;
1612+ model . createdAt . should . be . instanceOf ( Date ) ;
1613+ ( model . createdAt >= now ) . should . be . true ;
15991614 } ) ;
16001615
16011616 done ( ) ;
@@ -1614,10 +1629,10 @@ describe('manipulation', function() {
16141629
16151630 it ( 'should report \'$now\' as default value for string property' ,
16161631 function ( done ) {
1617- var myCustomModel = CustomModel . create ( function ( err , m ) {
1618- should . not . exists ( err ) ;
1619- m . now . should . be . instanceOf ( String ) ;
1620- m . now . should . equal ( '$now' ) ;
1632+ CustomModel . create ( function ( err , model ) {
1633+ if ( err ) return done ( err ) ;
1634+ model . now . should . be . instanceOf ( String ) ;
1635+ model . now . should . equal ( '$now' ) ;
16211636 } ) ;
16221637
16231638 done ( ) ;
@@ -1637,10 +1652,10 @@ describe('manipulation', function() {
16371652 it ( 'should generate current time when "defaultFn" is "now"' ,
16381653 function ( done ) {
16391654 var now = Date . now ( ) ;
1640- var inst = CustomModel . create ( function ( err , m ) {
1641- should . not . exists ( err ) ;
1642- m . now . should . be . instanceOf ( Date ) ;
1643- m . now . should . be . within ( now , now + 200 ) ;
1655+ CustomModel . create ( function ( err , model ) {
1656+ if ( err ) return done ( err ) ;
1657+ model . now . should . be . instanceOf ( Date ) ;
1658+ model . now . should . be . within ( now , now + 200 ) ;
16441659 done ( ) ;
16451660 } ) ;
16461661 } ) ;
@@ -1657,9 +1672,9 @@ describe('manipulation', function() {
16571672 } ) ;
16581673
16591674 it ( 'should generate a new id when "defaultFn" is "guid"' , function ( done ) {
1660- var inst = CustomModel . create ( function ( err , m ) {
1661- should . not . exists ( err ) ;
1662- m . guid . should . match ( UUID_REGEXP ) ;
1675+ CustomModel . create ( function ( err , model ) {
1676+ if ( err ) return done ( err ) ;
1677+ model . guid . should . match ( UUID_REGEXP ) ;
16631678 done ( ) ;
16641679 } ) ;
16651680 } ) ;
@@ -1676,9 +1691,9 @@ describe('manipulation', function() {
16761691 } ) ;
16771692
16781693 it ( 'should generate a new id when "defaultfn" is "uuid"' , function ( done ) {
1679- var inst = CustomModel . create ( function ( err , m ) {
1680- should . not . exists ( err ) ;
1681- m . guid . should . match ( UUID_REGEXP ) ;
1694+ CustomModel . create ( function ( err , model ) {
1695+ if ( err ) return done ( err ) ;
1696+ model . guid . should . match ( UUID_REGEXP ) ;
16821697 done ( ) ;
16831698 } ) ;
16841699 } ) ;
@@ -1695,9 +1710,9 @@ describe('manipulation', function() {
16951710 } ) ;
16961711
16971712 it ( 'should generate a new id when "defaultfn" is "uuidv4"' , function ( done ) {
1698- var inst = CustomModel . create ( function ( err , m ) {
1713+ CustomModel . create ( function ( err , model ) {
16991714 should . not . exists ( err ) ;
1700- m . guid . should . match ( UUID_REGEXP ) ;
1715+ model . guid . should . match ( UUID_REGEXP ) ;
17011716 done ( ) ;
17021717 } ) ;
17031718 } ) ;
0 commit comments