@@ -4190,7 +4190,7 @@ describe('relations', function() {
41904190 tmp = getTransientDataSource ( ) ;
41914191 // db = getSchema();
41924192 Person = db . define ( 'Person' , { name : String } ) ;
4193- Address = tmp . define ( 'Address' , { street : String } ) ;
4193+ Address = tmp . define ( 'Address' , { street : String } , { forceId : false } ) ;
41944194 Address . validatesPresenceOf ( 'street' ) ;
41954195
41964196 db . automigrate ( [ 'Person' ] , done ) ;
@@ -4488,7 +4488,7 @@ describe('relations', function() {
44884488 // db = getSchema();
44894489 Category = db . define ( 'Category' , { name : String } ) ;
44904490 Job = db . define ( 'Job' , { name : String } ) ;
4491- Link = db . define ( 'Link' , { name : String , notes : String } ) ;
4491+ Link = db . define ( 'Link' , { name : String , notes : String } , { forceId : false } ) ;
44924492 } ) ;
44934493
44944494 it ( 'can be declared' , function ( done ) {
@@ -4509,10 +4509,13 @@ describe('relations', function() {
45094509
45104510 it ( 'should setup related items' , function ( done ) {
45114511 Job . create ( { name : 'Job 1' } , function ( err , p ) {
4512+ if ( err ) return done ( err ) ;
45124513 job1 = p ;
45134514 Job . create ( { name : 'Job 2' } , function ( err , p ) {
4515+ if ( err ) return done ( err ) ;
45144516 job2 = p ;
45154517 Job . create ( { name : 'Job 3' } , function ( err , p ) {
4518+ if ( err ) return done ( err ) ;
45164519 job3 = p ;
45174520 done ( ) ;
45184521 } ) ;
@@ -4522,11 +4525,13 @@ describe('relations', function() {
45224525
45234526 it ( 'should associate items on scope' , function ( done ) {
45244527 Category . create ( { name : 'Category A' } , function ( err , cat ) {
4528+ if ( err ) return done ( err ) ;
45254529 var link = cat . items . build ( ) ;
45264530 link . job ( job1 ) ;
45274531 var link = cat . items . build ( ) ;
45284532 link . job ( job2 ) ;
45294533 cat . save ( function ( err , cat ) {
4534+ if ( err ) return done ( err ) ;
45304535 var job = cat . items . at ( 0 ) ;
45314536 job . should . be . instanceof ( Link ) ;
45324537 job . should . not . have . property ( 'jobId' ) ;
@@ -4542,6 +4547,7 @@ describe('relations', function() {
45424547
45434548 it ( 'should include related items on scope' , function ( done ) {
45444549 Category . findOne ( function ( err , cat ) {
4550+ if ( err ) return done ( err ) ;
45454551 cat . links . should . have . length ( 2 ) ;
45464552
45474553 // denormalized properties:
@@ -4556,6 +4562,7 @@ describe('relations', function() {
45564562 should . not . exist ( cat . items . at ( 1 ) . job ( ) ) ;
45574563
45584564 cat . items ( function ( err , items ) {
4565+ if ( err ) return done ( err ) ;
45594566 cat . items . at ( 0 ) . job ( ) . should . be . instanceof ( Job ) ;
45604567 cat . items . at ( 1 ) . job ( ) . should . be . instanceof ( Job ) ;
45614568 cat . items . at ( 1 ) . job ( ) . name . should . equal ( 'Job 2' ) ;
@@ -4566,8 +4573,10 @@ describe('relations', function() {
45664573
45674574 it ( 'should remove embedded items by id' , function ( done ) {
45684575 Category . findOne ( function ( err , cat ) {
4576+ if ( err ) return done ( err ) ;
45694577 cat . links . should . have . length ( 2 ) ;
45704578 cat . items . destroy ( job1 . id , function ( err ) {
4579+ if ( err ) return done ( err ) ;
45714580 should . not . exist ( err ) ;
45724581 cat . links . should . have . length ( 1 ) ;
45734582 done ( ) ;
@@ -4577,6 +4586,7 @@ describe('relations', function() {
45774586
45784587 it ( 'should find items on scope' , function ( done ) {
45794588 Category . findOne ( function ( err , cat ) {
4589+ if ( err ) return done ( err ) ;
45804590 cat . links . should . have . length ( 1 ) ;
45814591 cat . items . at ( 0 ) . id . should . eql ( job2 . id ) ;
45824592 cat . items . at ( 0 ) . name . should . equal ( job2 . name ) ;
@@ -4585,6 +4595,7 @@ describe('relations', function() {
45854595 should . not . exist ( cat . items . at ( 0 ) . job ( ) ) ;
45864596
45874597 cat . items ( function ( err , items ) {
4598+ if ( err ) return done ( err ) ;
45884599 cat . items . at ( 0 ) . job ( ) . should . be . instanceof ( Job ) ;
45894600 cat . items . at ( 0 ) . job ( ) . name . should . equal ( 'Job 2' ) ;
45904601 done ( ) ;
@@ -4594,8 +4605,10 @@ describe('relations', function() {
45944605
45954606 it ( 'should add related items to scope' , function ( done ) {
45964607 Category . findOne ( function ( err , cat ) {
4608+ if ( err ) return done ( err ) ;
45974609 cat . links . should . have . length ( 1 ) ;
45984610 cat . items . add ( job3 , function ( err , link ) {
4611+ if ( err ) return done ( err ) ;
45994612 link . should . be . instanceof ( Link ) ;
46004613 link . id . should . eql ( job3 . id ) ;
46014614 link . name . should . equal ( 'Job 3' ) ;
@@ -4608,6 +4621,7 @@ describe('relations', function() {
46084621
46094622 it ( 'should find items on scope' , function ( done ) {
46104623 Category . findOne ( function ( err , cat ) {
4624+ if ( err ) return done ( err ) ;
46114625 cat . links . should . have . length ( 2 ) ;
46124626
46134627 cat . items . at ( 0 ) . should . be . instanceof ( Link ) ;
@@ -4622,8 +4636,10 @@ describe('relations', function() {
46224636
46234637 it ( 'should remove embedded items by reference id' , function ( done ) {
46244638 Category . findOne ( function ( err , cat ) {
4639+ if ( err ) return done ( err ) ;
46254640 cat . links . should . have . length ( 2 ) ;
46264641 cat . items . remove ( job2 . id , function ( err ) {
4642+ if ( err ) return done ( err ) ;
46274643 should . not . exist ( err ) ;
46284644 cat . links . should . have . length ( 1 ) ;
46294645 done ( ) ;
@@ -4633,6 +4649,7 @@ describe('relations', function() {
46334649
46344650 it ( 'should have removed embedded items by reference id' , function ( done ) {
46354651 Category . findOne ( function ( err , cat ) {
4652+ if ( err ) return done ( err ) ;
46364653 cat . links . should . have . length ( 1 ) ;
46374654 done ( ) ;
46384655 } ) ;
@@ -4642,9 +4659,11 @@ describe('relations', function() {
46424659
46434660 it ( 'should create items on scope' , function ( done ) {
46444661 Category . create ( { name : 'Category B' } , function ( err , cat ) {
4662+ if ( err ) return done ( err ) ;
46454663 category = cat ;
46464664 var link = cat . items . build ( { notes : 'Some notes...' } ) ;
46474665 link . job . create ( { name : 'Job 1' } , function ( err , p ) {
4666+ if ( err ) return done ( err ) ;
46484667 jobId = p . id ;
46494668 cat . links [ 0 ] . id . should . eql ( p . id ) ;
46504669 cat . links [ 0 ] . name . should . equal ( 'Job 1' ) ; // denormalized
@@ -4657,12 +4676,14 @@ describe('relations', function() {
46574676
46584677 it ( 'should find items on scope' , function ( done ) {
46594678 Category . findById ( category . id , function ( err , cat ) {
4679+ if ( err ) return done ( err ) ;
46604680 cat . name . should . equal ( 'Category B' ) ;
46614681 cat . links . toObject ( ) . should . eql ( [
46624682 { id : jobId , name : 'Job 1' , notes : 'Some notes...' } ,
46634683 ] ) ;
46644684 cat . items . at ( 0 ) . should . equal ( cat . links [ 0 ] ) ;
46654685 cat . items ( function ( err , items ) { // alternative access
4686+ if ( err ) return done ( err ) ;
46664687 items . should . be . an . array ;
46674688 items . should . have . length ( 1 ) ;
46684689 items [ 0 ] . job ( function ( err , p ) {
@@ -4675,8 +4696,10 @@ describe('relations', function() {
46754696
46764697 it ( 'should update items on scope - and save parent' , function ( done ) {
46774698 Category . findById ( category . id , function ( err , cat ) {
4699+ if ( err ) return done ( err ) ;
46784700 var link = cat . items . at ( 0 ) ;
46794701 link . updateAttributes ( { notes : 'Updated notes...' } , function ( err , link ) {
4702+ if ( err ) return done ( err ) ;
46804703 link . notes . should . equal ( 'Updated notes...' ) ;
46814704 done ( ) ;
46824705 } ) ;
@@ -4685,6 +4708,7 @@ describe('relations', function() {
46854708
46864709 it ( 'should find items on scope - verify update' , function ( done ) {
46874710 Category . findById ( category . id , function ( err , cat ) {
4711+ if ( err ) return done ( err ) ;
46884712 cat . name . should . equal ( 'Category B' ) ;
46894713 cat . links . toObject ( ) . should . eql ( [
46904714 { id : jobId , name : 'Job 1' , notes : 'Updated notes...' } ,
@@ -4695,7 +4719,9 @@ describe('relations', function() {
46954719
46964720 it ( 'should remove items from scope - and save parent' , function ( done ) {
46974721 Category . findById ( category . id , function ( err , cat ) {
4722+ if ( err ) return done ( err ) ;
46984723 cat . items . at ( 0 ) . destroy ( function ( err , link ) {
4724+ if ( err ) return done ( err ) ;
46994725 cat . links . should . eql ( [ ] ) ;
47004726 done ( ) ;
47014727 } ) ;
@@ -4704,6 +4730,7 @@ describe('relations', function() {
47044730
47054731 it ( 'should find items on scope - verify destroy' , function ( done ) {
47064732 Category . findById ( category . id , function ( err , cat ) {
4733+ if ( err ) return done ( err ) ;
47074734 cat . name . should . equal ( 'Category B' ) ;
47084735 cat . links . should . eql ( [ ] ) ;
47094736 done ( ) ;
0 commit comments