@@ -612,7 +612,7 @@ class ::DummyIndexingModelForRecreate
612
612
context 'when the index is not found' do
613
613
614
614
let ( :client ) do
615
- double ( 'client' , indices : indices )
615
+ double ( 'client' , indices : indices , transport : double ( 'transport' , { logger : nil } ) )
616
616
end
617
617
618
618
let ( :indices ) do
@@ -622,14 +622,34 @@ class ::DummyIndexingModelForRecreate
622
622
end
623
623
624
624
before do
625
- expect ( DummyIndexingModelForRecreate ) . to receive ( :client ) . and_return ( client )
625
+ expect ( DummyIndexingModelForRecreate ) . to receive ( :client ) . at_most ( 3 ) . times . and_return ( client )
626
626
end
627
627
628
628
context 'when the force option is true' do
629
629
630
630
it 'deletes the index without raising an exception' do
631
631
expect ( DummyIndexingModelForRecreate . delete_index! ( force : true ) ) . to be_nil
632
632
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
633
653
end
634
654
635
655
context 'when the force option is not provided' do
@@ -799,6 +819,8 @@ class ::DummyIndexingModelForCreate
799
819
expect ( DummyIndexingModelForCreate . create_index! ( index : 'custom-foo' ) )
800
820
end
801
821
end
822
+
823
+ context 'when the logging level is debug'
802
824
end
803
825
804
826
describe '#refresh_index!' do
@@ -824,15 +846,15 @@ class ::DummyIndexingModelForRefresh
824
846
end
825
847
826
848
let ( :client ) do
827
- double ( 'client' , indices : indices )
849
+ double ( 'client' , indices : indices , transport : double ( 'transport' , { logger : nil } ) )
828
850
end
829
851
830
852
let ( :indices ) do
831
853
double ( 'indices' )
832
854
end
833
855
834
856
before do
835
- expect ( DummyIndexingModelForRefresh ) . to receive ( :client ) . and_return ( client )
857
+ expect ( DummyIndexingModelForRefresh ) . to receive ( :client ) . at_most ( 3 ) . times . and_return ( client )
836
858
end
837
859
838
860
context 'when the force option is true' do
@@ -846,6 +868,26 @@ class ::DummyIndexingModelForRefresh
846
868
it 'does not raise an exception' do
847
869
expect ( DummyIndexingModelForRefresh . refresh_index! ( force : true ) ) . to be_nil
848
870
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
849
891
end
850
892
851
893
context 'when the operation raises another type of exception' do
0 commit comments