Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion elasticsearch-model/lib/elasticsearch/model/importing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def import(options={}, &block)
errors += response['items'].select { |k, v| k.values.first['error'] }
end

self.refresh_index! if refresh
self.refresh_index! index: target_index if refresh

case return_value
when 'errors'
Expand Down
21 changes: 21 additions & 0 deletions elasticsearch-model/test/unit/importing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,27 @@ def importing_mixin
end
end

context "with the refresh option" do
should "refresh the index" do
DummyImportingModel.expects(:__find_in_batches).with do |options|
assert_equal 'bar', options[:foo]
assert_nil options[:refresh]
true
end

DummyImportingModel.expects(:refresh_index!).with do |options|
assert_equal 'foo', options[:index]
true
end

DummyImportingModel.expects(:index_name).returns('foo')
DummyImportingModel.expects(:document_type).returns('foo')
DummyImportingModel.stubs(:index_exists?).returns(true)

DummyImportingModel.import refresh: true, foo: 'bar'
end
end

should "allow passing a different index / type" do
Elasticsearch::Model::Adapter.expects(:from_class)
.with(DummyImportingModel)
Expand Down