Skip to content

Commit 1c34f6c

Browse files
committed
Fix specs to include body in spec_helper
1 parent 16e53f5 commit 1c34f6c

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

elasticsearch-model/spec/elasticsearch/model/adapters/active_record/import_spec.rb

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
require 'spec_helper'
1919

2020
describe 'Elasticsearch::Model::Adapter::ActiveRecord Importing' do
21-
2221
before(:all) do
2322
ActiveRecord::Schema.define(:version => 1) do
2423
create_table :import_articles do |t|
@@ -43,11 +42,9 @@
4342
end
4443

4544
describe '#import' do
46-
4745
context 'when no search criteria is specified' do
48-
4946
before do
50-
10.times { |i| ImportArticle.create! title: 'Test', views: "#{i}" }
47+
10.times { |i| ImportArticle.create! title: 'Test', views: i.to_s }
5148
ImportArticle.import
5249
ImportArticle.__elasticsearch__.refresh_index!
5350
end
@@ -58,7 +55,6 @@
5855
end
5956

6057
context 'when batch size is specified' do
61-
6258
before do
6359
10.times { |i| ImportArticle.create! title: 'Test', views: "#{i}" }
6460
end
@@ -82,7 +78,6 @@
8278
end
8379

8480
context 'when a scope is specified' do
85-
8681
before do
8782
10.times { |i| ImportArticle.create! title: 'Test', views: "#{i}" }
8883
ImportArticle.import(scope: 'popular', force: true)
@@ -95,7 +90,6 @@
9590
end
9691

9792
context 'when a query is specified' do
98-
9993
before do
10094
10.times { |i| ImportArticle.create! title: 'Test', views: "#{i}" }
10195
ImportArticle.import(query: -> { where('views >= 3') })
@@ -108,7 +102,6 @@
108102
end
109103

110104
context 'when there are invalid documents' do
111-
112105
let!(:result) do
113106
10.times { |i| ImportArticle.create! title: 'Test', views: "#{i}" }
114107
new_article
@@ -132,7 +125,6 @@
132125
end
133126

134127
context 'when a transform proc is specified' do
135-
136128
before do
137129
10.times { |i| ImportArticle.create! title: 'Test', views: "#{i}" }
138130
ImportArticle.import( transform: ->(a) {{ index: { data: { name: a.title, foo: 'BAR' } }}} )
@@ -151,7 +143,6 @@
151143
end
152144

153145
context 'when the model has a default scope' do
154-
155146
around(:all) do |example|
156147
10.times { |i| ImportArticle.create! title: 'Test', views: "#{i}" }
157148
ImportArticle.instance_eval { default_scope { where('views > 3') } }
@@ -170,7 +161,6 @@
170161
end
171162

172163
context 'when there is a default scope and a query specified' do
173-
174164
around(:all) do |example|
175165
10.times { |i| ImportArticle.create! title: 'Test', views: "#{i}" }
176166
ImportArticle.instance_eval { default_scope { where('views > 3') } }
@@ -189,7 +179,6 @@
189179
end
190180

191181
context 'when the batch is empty' do
192-
193182
before do
194183
ImportArticle.delete_all
195184
ImportArticle.import

elasticsearch-model/spec/spec_helper.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,16 @@ def active_record_at_least_4?
8181
# @since 6.0.1
8282
def clear_indices(*models)
8383
models.each do |model|
84-
begin; Elasticsearch::Model.client.delete_by_query(index: model.index_name, q: '*'); rescue; end
85-
end and true
84+
begin
85+
Elasticsearch::Model.client.delete_by_query(
86+
index: model.index_name,
87+
q: '*',
88+
body: {}
89+
)
90+
rescue
91+
end
92+
end
93+
true
8694
end
8795

8896
# Delete all documents from the tables of the provided list of models.

0 commit comments

Comments
 (0)