Skip to content

Commit 5d5df63

Browse files
committed
[MODEL] Updates ES client spec for client 7.14.0
1 parent f050042 commit 5d5df63

File tree

3 files changed

+21
-22
lines changed

3 files changed

+21
-22
lines changed

elasticsearch-model/spec/elasticsearch/model/client_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ class ::DummyClientModel
3333
context 'when a class includes the client module class methods' do
3434

3535
it 'defines the client module class methods on the model' do
36-
expect(DummyClientModel.client).to be_a(Elasticsearch::Transport::Client)
36+
expect(DummyClientModel.client).to be_a(Elasticsearch::Client)
3737
end
3838
end
3939

4040
context 'when a class includes the client module instance methods' do
4141

4242
it 'defines the client module class methods on the model' do
43-
expect(DummyClientModel.new.client).to be_a(Elasticsearch::Transport::Client)
43+
expect(DummyClientModel.new.client).to be_a(Elasticsearch::Client)
4444
end
4545
end
4646

@@ -77,7 +77,7 @@ class ::DummyClientModel
7777
end
7878

7979
it 'does not set the client on the class' do
80-
expect(DummyClientModel.client).to be_a(Elasticsearch::Transport::Client)
80+
expect(DummyClientModel.client).to be_a(Elasticsearch::Client)
8181
end
8282
end
8383
end

elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb

+17-18
Original file line numberDiff line numberDiff line change
@@ -676,15 +676,13 @@ class ::DummyIndexingModelForRecreate
676676
end
677677

678678
context 'when the index is not found' do
679+
let(:logger) { nil }
680+
let(:transport) do
681+
Elasticsearch::Transport::Client.new(logger: logger)
682+
end
683+
679684
let(:client) do
680-
double(
681-
'client',
682-
indices: indices,
683-
transport: double(
684-
'transport',
685-
double('transport', { logger: nil })
686-
)
687-
)
685+
double('client', indices: indices, transport: transport)
688686
end
689687

690688
let(:indices) do
@@ -698,19 +696,17 @@ class ::DummyIndexingModelForRecreate
698696
end
699697

700698
context 'when the force option is true' do
701-
702699
it 'deletes the index without raising an exception' do
703700
expect(DummyIndexingModelForRecreate.delete_index!(force: true)).to be_nil
704701
end
705702

706703
context 'when the client has a logger' do
707-
708704
let(:logger) do
709705
Logger.new(STDOUT).tap { |l| l.level = Logger::DEBUG }
710706
end
711707

712708
let(:client) do
713-
double('client', indices: indices, transport: double('transport', { logger: logger }))
709+
double('client', indices: indices, transport: transport)
714710
end
715711

716712
it 'deletes the index without raising an exception' do
@@ -918,7 +914,11 @@ class ::DummyIndexingModelForRefresh
918914
end
919915

920916
let(:client) do
921-
double('client', indices: indices, transport: double('transport', { logger: nil }))
917+
double('client', indices: indices, transport: transport)
918+
end
919+
920+
let(:transport) do
921+
Elasticsearch::Transport::Client.new(logger: nil)
922922
end
923923

924924
let(:indices) do
@@ -930,9 +930,7 @@ class ::DummyIndexingModelForRefresh
930930
end
931931

932932
context 'when the force option is true' do
933-
934933
context 'when the operation raises a NotFound exception' do
935-
936934
before do
937935
expect(indices).to receive(:refresh).and_raise(NotFound)
938936
end
@@ -942,13 +940,16 @@ class ::DummyIndexingModelForRefresh
942940
end
943941

944942
context 'when the client has a logger' do
945-
946943
let(:logger) do
947944
Logger.new(STDOUT).tap { |l| l.level = Logger::DEBUG }
948945
end
949946

950947
let(:client) do
951-
double('client', indices: indices, transport: double('transport', { logger: logger }))
948+
double('client', indices: indices, transport: transport)
949+
end
950+
951+
let(:transport) do
952+
Elasticsearch::Transport::Client.new(logger: logger)
952953
end
953954

954955
it 'does not raise an exception' do
@@ -963,7 +964,6 @@ class ::DummyIndexingModelForRefresh
963964
end
964965

965966
context 'when the operation raises another type of exception' do
966-
967967
before do
968968
expect(indices).to receive(:refresh).and_raise(Exception)
969969
end
@@ -977,7 +977,6 @@ class ::DummyIndexingModelForRefresh
977977
end
978978

979979
context 'when an index name is provided in the options' do
980-
981980
before do
982981
expect(indices).to receive(:refresh).with(index: 'custom-foo')
983982
end

elasticsearch-model/spec/elasticsearch/model/module_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
describe '#client' do
2323

2424
it 'should have a default' do
25-
expect(Elasticsearch::Model.client).to be_a(Elasticsearch::Transport::Client)
25+
expect(Elasticsearch::Model.client).to be_a(Elasticsearch::Client)
2626
end
2727
end
2828

0 commit comments

Comments
 (0)