File tree 2 files changed +22
-1
lines changed
2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -130,7 +130,7 @@ def import(options={}, &block)
130
130
errors += response [ 'items' ] . select { |k , v | k . values . first [ 'error' ] }
131
131
end
132
132
133
- self . refresh_index! if refresh
133
+ self . refresh_index! index : target_index if refresh
134
134
135
135
case return_value
136
136
when 'errors'
Original file line number Diff line number Diff line change @@ -146,6 +146,27 @@ def importing_mixin
146
146
end
147
147
end
148
148
149
+ context "with the refresh option" do
150
+ should "refresh the index" do
151
+ DummyImportingModel . expects ( :__find_in_batches ) . with do |options |
152
+ assert_equal 'bar' , options [ :foo ]
153
+ assert_nil options [ :refresh ]
154
+ true
155
+ end
156
+
157
+ DummyImportingModel . expects ( :refresh_index! ) . with do |options |
158
+ assert_equal 'foo' , options [ :index ]
159
+ true
160
+ end
161
+
162
+ DummyImportingModel . expects ( :index_name ) . returns ( 'foo' )
163
+ DummyImportingModel . expects ( :document_type ) . returns ( 'foo' )
164
+ DummyImportingModel . stubs ( :index_exists? ) . returns ( true )
165
+
166
+ DummyImportingModel . import refresh : true , foo : 'bar'
167
+ end
168
+ end
169
+
149
170
should "allow passing a different index / type" do
150
171
Elasticsearch ::Model ::Adapter . expects ( :from_class )
151
172
. with ( DummyImportingModel )
You can’t perform that action at this time.
0 commit comments