@@ -279,7 +279,7 @@ describe('Flow Service', () => {
279279
280280 beforeEach ( ( ) => {
281281 $sandbox . stub ( Validator , 'validate' ) . returns ( $validatorResponse ) ;
282- $sandbox . stub ( FlowManager , 'findOneExcludeFields ' ) . returns ( $findExcludedFlowResponse ) ;
282+ $sandbox . stub ( FlowManager , 'findOneWithAttributes ' ) . returns ( $findExcludedFlowResponse ) ;
283283 $sandbox . stub ( FlowManager , 'findOne' ) . returns ( $findFlowResponse ) ;
284284 $sandbox . stub ( AppHelper , 'deleteUndefinedFields' ) . returns ( $deleteUndefinedFieldsResponse ) ;
285285 $sandbox . stub ( FlowManager , 'update' ) . returns ( $updateFlowResponse ) ;
@@ -301,24 +301,25 @@ describe('Flow Service', () => {
301301 } ) ;
302302
303303 context ( 'when Validator#validate() succeeds' , ( ) => {
304- it ( 'calls FlowManager#findOneExcludeFields () with correct args' , async ( ) => {
304+ it ( 'calls FlowManager#findOneWithAttributes () with correct args' , async ( ) => {
305305 await $subject ;
306306
307307 const where = isCLI
308308 ? { id : flowId }
309309 : { id : flowId , userId : user . id } ;
310- expect ( FlowManager . findOneExcludeFields ) . to . have . been . calledWith ( where , transaction ) ;
310+ const attributes = { exclude : [ "created_at" , "updated_at" ] } ;
311+ expect ( FlowManager . findOneWithAttributes ) . to . have . been . calledWith ( where , attributes , transaction ) ;
311312 } ) ;
312313
313- context ( 'when FlowManager#findOneExcludeFields () fails' , ( ) => {
314+ context ( 'when FlowManager#findOneWithAttributes () fails' , ( ) => {
314315 def ( 'findExcludedFlowResponse' , ( ) => Promise . reject ( error ) ) ;
315316
316317 it ( `fails with ${ error } ` , ( ) => {
317318 return expect ( $subject ) . to . be . rejectedWith ( error ) ;
318319 } )
319320 } ) ;
320321
321- context ( 'when FlowManager#findOneExcludeFields () succeeds' , ( ) => {
322+ context ( 'when FlowManager#findOneWithAttributes () succeeds' , ( ) => {
322323 it ( 'calls FlowManager#findOne() with correct args' , async ( ) => {
323324 await $subject ;
324325
@@ -433,23 +434,24 @@ describe('Flow Service', () => {
433434 def ( 'findExcludedFlowResponse' , ( ) => Promise . resolve ( ) ) ;
434435
435436 beforeEach ( ( ) => {
436- $sandbox . stub ( FlowManager , 'findAllExcludeFields ' ) . returns ( $findExcludedFlowResponse ) ;
437+ $sandbox . stub ( FlowManager , 'findAllWithAttributes ' ) . returns ( $findExcludedFlowResponse ) ;
437438 } ) ;
438439
439- it ( 'calls FlowManager#findAllExcludeFields () with correct args' , async ( ) => {
440+ it ( 'calls FlowManager#findAllWithAttributes () with correct args' , async ( ) => {
440441 await $subject ;
441- expect ( FlowManager . findAllExcludeFields ) . to . have . been . calledWith ( flow , transaction ) ;
442+ const attributes = { exclude : [ "created_at" , "updated_at" ] } ;
443+ expect ( FlowManager . findAllWithAttributes ) . to . have . been . calledWith ( flow , attributes , transaction ) ;
442444 } ) ;
443445
444- context ( 'when FlowManager#findAllExcludeFields () fails' , ( ) => {
446+ context ( 'when FlowManager#findAllWithAttributes () fails' , ( ) => {
445447 def ( 'findExcludedFlowResponse' , ( ) => Promise . reject ( error ) ) ;
446448
447449 it ( `fails with ${ error } ` , ( ) => {
448450 return expect ( $subject ) . to . be . rejectedWith ( error ) ;
449451 } )
450452 } ) ;
451453
452- context ( 'when FlowManager#findAllExcludeFields () succeeds' , ( ) => {
454+ context ( 'when FlowManager#findAllWithAttributes () succeeds' , ( ) => {
453455 it ( 'fulfills the promise' , ( ) => {
454456 return expect ( $subject ) . to . eventually . have . property ( 'flows' ) ;
455457 } )
@@ -465,23 +467,24 @@ describe('Flow Service', () => {
465467 def ( 'findAllFlowsResponse' , ( ) => Promise . resolve ( ) ) ;
466468
467469 beforeEach ( ( ) => {
468- $sandbox . stub ( FlowManager , 'findAll ' ) . returns ( $findAllFlowsResponse ) ;
470+ $sandbox . stub ( FlowManager , 'findAllWithAttributes ' ) . returns ( $findAllFlowsResponse ) ;
469471 } ) ;
470472
471- it ( 'calls FlowManager#findAll () with correct args' , async ( ) => {
473+ it ( 'calls FlowManager#findAllWithAttributes () with correct args' , async ( ) => {
472474 await $subject ;
473- expect ( FlowManager . findAll ) . to . have . been . calledWith ( { } , transaction ) ;
475+ const attributes = { exclude : [ 'created_at' , 'updated_at' ] } ;
476+ expect ( FlowManager . findAllWithAttributes ) . to . have . been . calledWith ( { } , attributes , transaction ) ;
474477 } ) ;
475478
476- context ( 'when FlowManager#findAll () fails' , ( ) => {
479+ context ( 'when FlowManager#findAllWithAttributes () fails' , ( ) => {
477480 def ( 'findAllFlowsResponse' , ( ) => Promise . reject ( error ) ) ;
478481
479482 it ( `fails with ${ error } ` , ( ) => {
480483 return expect ( $subject ) . to . be . rejectedWith ( error ) ;
481484 } )
482485 } ) ;
483486
484- context ( 'when FlowManager#findAll () succeeds' , ( ) => {
487+ context ( 'when FlowManager#findAllWithAttributes () succeeds' , ( ) => {
485488 it ( 'fulfills the promise' , ( ) => {
486489 return expect ( $subject ) . to . eventually . have . property ( 'flows' ) ;
487490 } )
@@ -502,26 +505,27 @@ describe('Flow Service', () => {
502505 def ( 'findFlowResponse' , ( ) => Promise . resolve ( { } ) ) ;
503506
504507 beforeEach ( ( ) => {
505- $sandbox . stub ( FlowManager , 'findOneExcludeFields ' ) . returns ( $findFlowResponse ) ;
508+ $sandbox . stub ( FlowManager , 'findOneWithAttributes ' ) . returns ( $findFlowResponse ) ;
506509 } ) ;
507510
508- it ( 'calls FlowManager#findOneExcludeFields () with correct args' , async ( ) => {
511+ it ( 'calls FlowManager#findOneWithAttributes () with correct args' , async ( ) => {
509512 await $subject ;
510513 const where = isCLI
511514 ? { id : flowId }
512515 : { id : flowId , userId : user . id } ;
513- expect ( FlowManager . findOneExcludeFields ) . to . have . been . calledWith ( where , transaction ) ;
516+ const attributes = { exclude : [ "created_at" , "updated_at" ] } ;
517+ expect ( FlowManager . findOneWithAttributes ) . to . have . been . calledWith ( where , attributes , transaction ) ;
514518 } ) ;
515519
516- context ( 'when FlowManager#findOneExcludeFields () fails' , ( ) => {
520+ context ( 'when FlowManager#findOneWithAttributes () fails' , ( ) => {
517521 def ( 'findFlowResponse' , ( ) => Promise . reject ( error ) ) ;
518522
519523 it ( `fails with ${ error } ` , ( ) => {
520524 return expect ( $subject ) . to . be . rejectedWith ( error ) ;
521525 } )
522526 } ) ;
523527
524- context ( 'when FlowManager#findOneExcludeFields () succeeds' , ( ) => {
528+ context ( 'when FlowManager#findOneWithAttributes () succeeds' , ( ) => {
525529 it ( 'fulfills the promise' , ( ) => {
526530 return expect ( $subject ) . to . eventually . deep . equal ( { } ) ;
527531 } )
0 commit comments