@@ -612,7 +612,7 @@ class ::DummyIndexingModelForRecreate
612612 context 'when the index is not found' do
613613
614614 let ( :client ) do
615- double ( 'client' , indices : indices )
615+ double ( 'client' , indices : indices , transport : double ( 'transport' , { logger : nil } ) )
616616 end
617617
618618 let ( :indices ) do
@@ -622,14 +622,34 @@ class ::DummyIndexingModelForRecreate
622622 end
623623
624624 before do
625- expect ( DummyIndexingModelForRecreate ) . to receive ( :client ) . and_return ( client )
625+ expect ( DummyIndexingModelForRecreate ) . to receive ( :client ) . at_most ( 3 ) . times . and_return ( client )
626626 end
627627
628628 context 'when the force option is true' do
629629
630630 it 'deletes the index without raising an exception' do
631631 expect ( DummyIndexingModelForRecreate . delete_index! ( force : true ) ) . to be_nil
632632 end
633+
634+ context 'when the client has a logger' do
635+
636+ let ( :logger ) do
637+ Logger . new ( STDOUT ) . tap { |l | l . level = Logger ::DEBUG }
638+ end
639+
640+ let ( :client ) do
641+ double ( 'client' , indices : indices , transport : double ( 'transport' , { logger : logger } ) )
642+ end
643+
644+ it 'deletes the index without raising an exception' do
645+ expect ( DummyIndexingModelForRecreate . delete_index! ( force : true ) ) . to be_nil
646+ end
647+
648+ it 'logs the message that the index is not found' do
649+ expect ( logger ) . to receive ( :debug )
650+ expect ( DummyIndexingModelForRecreate . delete_index! ( force : true ) ) . to be_nil
651+ end
652+ end
633653 end
634654
635655 context 'when the force option is not provided' do
@@ -799,6 +819,8 @@ class ::DummyIndexingModelForCreate
799819 expect ( DummyIndexingModelForCreate . create_index! ( index : 'custom-foo' ) )
800820 end
801821 end
822+
823+ context 'when the logging level is debug'
802824 end
803825
804826 describe '#refresh_index!' do
@@ -824,15 +846,15 @@ class ::DummyIndexingModelForRefresh
824846 end
825847
826848 let ( :client ) do
827- double ( 'client' , indices : indices )
849+ double ( 'client' , indices : indices , transport : double ( 'transport' , { logger : nil } ) )
828850 end
829851
830852 let ( :indices ) do
831853 double ( 'indices' )
832854 end
833855
834856 before do
835- expect ( DummyIndexingModelForRefresh ) . to receive ( :client ) . and_return ( client )
857+ expect ( DummyIndexingModelForRefresh ) . to receive ( :client ) . at_most ( 3 ) . times . and_return ( client )
836858 end
837859
838860 context 'when the force option is true' do
@@ -846,6 +868,26 @@ class ::DummyIndexingModelForRefresh
846868 it 'does not raise an exception' do
847869 expect ( DummyIndexingModelForRefresh . refresh_index! ( force : true ) ) . to be_nil
848870 end
871+
872+ context 'when the client has a logger' do
873+
874+ let ( :logger ) do
875+ Logger . new ( STDOUT ) . tap { |l | l . level = Logger ::DEBUG }
876+ end
877+
878+ let ( :client ) do
879+ double ( 'client' , indices : indices , transport : double ( 'transport' , { logger : logger } ) )
880+ end
881+
882+ it 'does not raise an exception' do
883+ expect ( DummyIndexingModelForRefresh . refresh_index! ( force : true ) ) . to be_nil
884+ end
885+
886+ it 'logs the message that the index is not found' do
887+ expect ( logger ) . to receive ( :debug )
888+ expect ( DummyIndexingModelForRefresh . refresh_index! ( force : true ) ) . to be_nil
889+ end
890+ end
849891 end
850892
851893 context 'when the operation raises another type of exception' do
0 commit comments