@@ -629,7 +629,7 @@ class ::DummyIndexingModelForRecreate
629
629
context 'when the index is not found' do
630
630
631
631
let ( :client ) do
632
- double ( 'client' , indices : indices )
632
+ double ( 'client' , indices : indices , transport : double ( 'transport' , { logger : nil } ) )
633
633
end
634
634
635
635
let ( :indices ) do
@@ -639,14 +639,34 @@ class ::DummyIndexingModelForRecreate
639
639
end
640
640
641
641
before do
642
- expect ( DummyIndexingModelForRecreate ) . to receive ( :client ) . and_return ( client )
642
+ expect ( DummyIndexingModelForRecreate ) . to receive ( :client ) . at_most ( 3 ) . times . and_return ( client )
643
643
end
644
644
645
645
context 'when the force option is true' do
646
646
647
647
it 'deletes the index without raising an exception' do
648
648
expect ( DummyIndexingModelForRecreate . delete_index! ( force : true ) ) . to be_nil
649
649
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
650
670
end
651
671
652
672
context 'when the force option is not provided' do
@@ -816,6 +836,8 @@ class ::DummyIndexingModelForCreate
816
836
expect ( DummyIndexingModelForCreate . create_index! ( index : 'custom-foo' ) )
817
837
end
818
838
end
839
+
840
+ context 'when the logging level is debug'
819
841
end
820
842
821
843
describe '#refresh_index!' do
@@ -841,15 +863,15 @@ class ::DummyIndexingModelForRefresh
841
863
end
842
864
843
865
let ( :client ) do
844
- double ( 'client' , indices : indices )
866
+ double ( 'client' , indices : indices , transport : double ( 'transport' , { logger : nil } ) )
845
867
end
846
868
847
869
let ( :indices ) do
848
870
double ( 'indices' )
849
871
end
850
872
851
873
before do
852
- expect ( DummyIndexingModelForRefresh ) . to receive ( :client ) . and_return ( client )
874
+ expect ( DummyIndexingModelForRefresh ) . to receive ( :client ) . at_most ( 3 ) . times . and_return ( client )
853
875
end
854
876
855
877
context 'when the force option is true' do
@@ -863,6 +885,26 @@ class ::DummyIndexingModelForRefresh
863
885
it 'does not raise an exception' do
864
886
expect ( DummyIndexingModelForRefresh . refresh_index! ( force : true ) ) . to be_nil
865
887
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
866
908
end
867
909
868
910
context 'when the operation raises another type of exception' do
0 commit comments