File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 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)
130130 errors += response [ 'items' ] . select { |k , v | k . values . first [ 'error' ] }
131131 end
132132
133- self . refresh_index! if refresh
133+ self . refresh_index! index : target_index if refresh
134134
135135 case return_value
136136 when 'errors'
Original file line number Diff line number Diff line change @@ -146,6 +146,27 @@ def importing_mixin
146146 end
147147 end
148148
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+
149170 should "allow passing a different index / type" do
150171 Elasticsearch ::Model ::Adapter . expects ( :from_class )
151172 . with ( DummyImportingModel )
You can’t perform that action at this time.
0 commit comments