@@ -1958,6 +1958,7 @@ describe('relations', function() {
19581958 it ( 'should find polymorphic items - author' , function ( done ) {
19591959 Author . findOne ( function ( err , author ) {
19601960 should . not . exists ( err ) ;
1961+ if ( ! author ) return done ( ) ;
19611962 author . pictures ( function ( err , pics ) {
19621963 should . not . exist ( err ) ;
19631964
@@ -2159,6 +2160,7 @@ describe('relations', function() {
21592160 } ) ;
21602161
21612162 it ( 'should get polymorphic relation through model - author' , function ( done ) {
2163+ if ( ! author ) return done ( ) ;
21622164 Author . findById ( author . id , function ( err , author ) {
21632165 should . not . exist ( err ) ;
21642166 author . name . should . equal ( 'Author 1' ) ;
@@ -2188,6 +2190,7 @@ describe('relations', function() {
21882190 it ( 'should include polymorphic items' , function ( done ) {
21892191 Author . find ( { include : 'pictures' } , function ( err , authors ) {
21902192 authors . should . have . length ( 1 ) ;
2193+ if ( ! authors ) return done ( ) ;
21912194 authors [ 0 ] . pictures ( function ( err , pics ) {
21922195 pics . should . have . length ( 2 ) ;
21932196 pics [ 0 ] . name . should . equal ( 'Author Pic 1' ) ;
@@ -2199,6 +2202,7 @@ describe('relations', function() {
21992202
22002203 var anotherPicture ;
22012204 it ( 'should add to a polymorphic relation - author' , function ( done ) {
2205+ if ( ! author ) return done ( ) ;
22022206 Author . findById ( author . id , function ( err , author ) {
22032207 Picture . create ( { name : 'Example' } , function ( err , p ) {
22042208 should . not . exist ( err ) ;
@@ -2216,6 +2220,7 @@ describe('relations', function() {
22162220 } ) ;
22172221
22182222 it ( 'should create polymorphic through model' , function ( done ) {
2223+ if ( ! anotherPicture ) return done ( ) ;
22192224 PictureLink . findOne ( { where : { pictureId : anotherPicture . id , imageableType : 'Author' } } ,
22202225 function ( err , link ) {
22212226 should . not . exist ( err ) ;
@@ -2231,6 +2236,7 @@ describe('relations', function() {
22312236 Author . create ( { name : 'Author 2' } , function ( err , author ) {
22322237 should . not . exist ( err ) ;
22332238 anotherAuthor = author ;
2239+ if ( ! anotherPicture ) return done ( ) ;
22342240 author . pictures . add ( anotherPicture . id , function ( err , p ) {
22352241 should . not . exist ( err ) ;
22362242 done ( ) ;
@@ -2242,6 +2248,7 @@ describe('relations', function() {
22422248 Reader . create ( { name : 'Reader 2' } , function ( err , reader ) {
22432249 should . not . exist ( err ) ;
22442250 anotherReader = reader ;
2251+ if ( ! anotherPicture ) return done ( ) ;
22452252 reader . pictures . add ( anotherPicture . id , function ( err , p ) {
22462253 should . not . exist ( err ) ;
22472254 done ( ) ;
@@ -2250,6 +2257,7 @@ describe('relations', function() {
22502257 } ) ;
22512258
22522259 it ( 'should get the inverse polymorphic relation - author' , function ( done ) {
2260+ if ( ! anotherPicture ) return done ( ) ;
22532261 Picture . findById ( anotherPicture . id , function ( err , p ) {
22542262 p . authors ( function ( err , authors ) {
22552263 authors . should . have . length ( 2 ) ;
@@ -2261,6 +2269,7 @@ describe('relations', function() {
22612269 } ) ;
22622270
22632271 it ( 'should get the inverse polymorphic relation - reader' , function ( done ) {
2272+ if ( ! anotherPicture ) return done ( ) ;
22642273 Picture . findById ( anotherPicture . id , function ( err , p ) {
22652274 p . readers ( function ( err , readers ) {
22662275 readers . should . have . length ( 1 ) ;
@@ -2271,6 +2280,7 @@ describe('relations', function() {
22712280 } ) ;
22722281
22732282 it ( 'should find polymorphic items - author' , function ( done ) {
2283+ if ( ! author ) return done ( ) ;
22742284 Author . findById ( author . id , function ( err , author ) {
22752285 author . pictures ( function ( err , pics ) {
22762286 pics . should . have . length ( 3 ) ;
@@ -2283,6 +2293,7 @@ describe('relations', function() {
22832293 } ) ;
22842294
22852295 it ( 'should check if polymorphic relation exists - author' , function ( done ) {
2296+ if ( ! author ) return done ( ) ;
22862297 Author . findById ( author . id , function ( err , author ) {
22872298 author . pictures . exists ( anotherPicture . id , function ( err , exists ) {
22882299 exists . should . be . true ;
@@ -2292,6 +2303,7 @@ describe('relations', function() {
22922303 } ) ;
22932304
22942305 it ( 'should remove from a polymorphic relation - author' , function ( done ) {
2306+ if ( ! author || ! anotherPicture ) return done ( ) ;
22952307 Author . findById ( author . id , function ( err , author ) {
22962308 author . pictures . remove ( anotherPicture . id , function ( err ) {
22972309 should . not . exist ( err ) ;
@@ -2301,6 +2313,7 @@ describe('relations', function() {
23012313 } ) ;
23022314
23032315 it ( 'should find polymorphic items - author' , function ( done ) {
2316+ if ( ! author ) return done ( ) ;
23042317 Author . findById ( author . id , function ( err , author ) {
23052318 author . pictures ( function ( err , pics ) {
23062319 pics . should . have . length ( 2 ) ;
@@ -2312,6 +2325,7 @@ describe('relations', function() {
23122325 } ) ;
23132326
23142327 it ( 'should check if polymorphic relation exists - author' , function ( done ) {
2328+ if ( ! author ) return done ( ) ;
23152329 Author . findById ( author . id , function ( err , author ) {
23162330 author . pictures . exists ( 7 , function ( err , exists ) {
23172331 exists . should . be . false ;
@@ -2321,6 +2335,7 @@ describe('relations', function() {
23212335 } ) ;
23222336
23232337 it ( 'should create polymorphic item through relation scope' , function ( done ) {
2338+ if ( ! anotherPicture ) return done ( ) ;
23242339 Picture . findById ( anotherPicture . id , function ( err , p ) {
23252340 p . authors . create ( { name : 'Author 3' } , function ( err , a ) {
23262341 should . not . exist ( err ) ;
@@ -2332,6 +2347,7 @@ describe('relations', function() {
23322347 } ) ;
23332348
23342349 it ( 'should create polymorphic through model - new author' , function ( done ) {
2350+ if ( ! author || ! anotherPicture ) return done ( ) ;
23352351 PictureLink . findOne ( { where : {
23362352 pictureId : anotherPicture . id , imageableId : author . id , imageableType : 'Author' ,
23372353 } } , function ( err , link ) {
@@ -2344,6 +2360,7 @@ describe('relations', function() {
23442360 } ) ;
23452361
23462362 it ( 'should find polymorphic items - new author' , function ( done ) {
2363+ if ( ! author ) return done ( ) ;
23472364 Author . findById ( author . id , function ( err , author ) {
23482365 author . pictures ( function ( err , pics ) {
23492366 pics . should . have . length ( 1 ) ;
0 commit comments