File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
elasticsearch-model/test/integration Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -163,6 +163,36 @@ class ::ImportArticle < ActiveRecord::Base
163
163
assert_equal 1 , ImportArticle . search ( '*' ) . results . total
164
164
end
165
165
end
166
+
167
+ context 'ActiveRecord importing when the batch is empty' do
168
+
169
+ setup do
170
+ Object . send ( :remove_const , :ImportArticle ) if defined? ( ImportArticle )
171
+ class ::ImportArticle < ActiveRecord ::Base
172
+ include Elasticsearch ::Model
173
+ mapping { indexes :title , type : 'text' }
174
+ end
175
+
176
+ ActiveRecord ::Schema . define ( :version => 1 ) do
177
+ create_table :import_articles do |t |
178
+ t . string :title
179
+ end
180
+ end
181
+
182
+ ImportArticle . delete_all
183
+ ImportArticle . __elasticsearch__ . delete_index! force : true
184
+ ImportArticle . __elasticsearch__ . create_index! force : true
185
+ ImportArticle . __elasticsearch__ . client . cluster . health wait_for_status : 'yellow'
186
+ end
187
+
188
+ should 'not make any requests to create documents to Elasticsearch' do
189
+ assert_equal 0 , ImportArticle . count
190
+ assert_equal 0 , ImportArticle . import
191
+
192
+ ImportArticle . __elasticsearch__ . refresh_index!
193
+ assert_equal 0 , ImportArticle . search ( '*' ) . results . total
194
+ end
195
+ end
166
196
end
167
197
end
168
198
end
You can’t perform that action at this time.
0 commit comments