@@ -629,7 +629,7 @@ class ::DummyIndexingModelForRecreate
629629 context 'when the index is not found' do
630630
631631 let ( :client ) do
632- double ( 'client' , indices : indices )
632+ double ( 'client' , indices : indices , transport : double ( 'transport' , { logger : nil } ) )
633633 end
634634
635635 let ( :indices ) do
@@ -639,14 +639,34 @@ class ::DummyIndexingModelForRecreate
639639 end
640640
641641 before do
642- expect ( DummyIndexingModelForRecreate ) . to receive ( :client ) . and_return ( client )
642+ expect ( DummyIndexingModelForRecreate ) . to receive ( :client ) . at_most ( 3 ) . times . and_return ( client )
643643 end
644644
645645 context 'when the force option is true' do
646646
647647 it 'deletes the index without raising an exception' do
648648 expect ( DummyIndexingModelForRecreate . delete_index! ( force : true ) ) . to be_nil
649649 end
650+
651+ context 'when the client has a logger' do
652+
653+ let ( :logger ) do
654+ Logger . new ( STDOUT ) . tap { |l | l . level = Logger ::DEBUG }
655+ end
656+
657+ let ( :client ) do
658+ double ( 'client' , indices : indices , transport : double ( 'transport' , { logger : logger } ) )
659+ end
660+
661+ it 'deletes the index without raising an exception' do
662+ expect ( DummyIndexingModelForRecreate . delete_index! ( force : true ) ) . to be_nil
663+ end
664+
665+ it 'logs the message that the index is not found' do
666+ expect ( logger ) . to receive ( :debug )
667+ expect ( DummyIndexingModelForRecreate . delete_index! ( force : true ) ) . to be_nil
668+ end
669+ end
650670 end
651671
652672 context 'when the force option is not provided' do
@@ -816,6 +836,8 @@ class ::DummyIndexingModelForCreate
816836 expect ( DummyIndexingModelForCreate . create_index! ( index : 'custom-foo' ) )
817837 end
818838 end
839+
840+ context 'when the logging level is debug'
819841 end
820842
821843 describe '#refresh_index!' do
@@ -841,15 +863,15 @@ class ::DummyIndexingModelForRefresh
841863 end
842864
843865 let ( :client ) do
844- double ( 'client' , indices : indices )
866+ double ( 'client' , indices : indices , transport : double ( 'transport' , { logger : nil } ) )
845867 end
846868
847869 let ( :indices ) do
848870 double ( 'indices' )
849871 end
850872
851873 before do
852- expect ( DummyIndexingModelForRefresh ) . to receive ( :client ) . and_return ( client )
874+ expect ( DummyIndexingModelForRefresh ) . to receive ( :client ) . at_most ( 3 ) . times . and_return ( client )
853875 end
854876
855877 context 'when the force option is true' do
@@ -863,6 +885,26 @@ class ::DummyIndexingModelForRefresh
863885 it 'does not raise an exception' do
864886 expect ( DummyIndexingModelForRefresh . refresh_index! ( force : true ) ) . to be_nil
865887 end
888+
889+ context 'when the client has a logger' do
890+
891+ let ( :logger ) do
892+ Logger . new ( STDOUT ) . tap { |l | l . level = Logger ::DEBUG }
893+ end
894+
895+ let ( :client ) do
896+ double ( 'client' , indices : indices , transport : double ( 'transport' , { logger : logger } ) )
897+ end
898+
899+ it 'does not raise an exception' do
900+ expect ( DummyIndexingModelForRefresh . refresh_index! ( force : true ) ) . to be_nil
901+ end
902+
903+ it 'logs the message that the index is not found' do
904+ expect ( logger ) . to receive ( :debug )
905+ expect ( DummyIndexingModelForRefresh . refresh_index! ( force : true ) ) . to be_nil
906+ end
907+ end
866908 end
867909
868910 context 'when the operation raises another type of exception' do
0 commit comments