File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ def index(docs)
4141 batch << [ doc , path ]
4242 else
4343 total_indexed += index_batch ( batch )
44- batch = [ ]
44+ batch = [ [ doc , path ] ]
4545 end
4646 end
4747 total_indexed += index_batch ( batch ) unless batch . empty?
Original file line number Diff line number Diff line change @@ -96,6 +96,18 @@ def self.connection; end
9696 )
9797 end
9898
99+ context 'when the number of docs is greater than batch size' do
100+ before do
101+ stub_const ( 'ENV' , 'SOLR_BATCH_SIZE' => 10 )
102+ end
103+
104+ let ( :docs ) { ( 1 ..40 ) . map { |n | [ { 'id' => n } , "path/to/record#{ n } .json" ] } }
105+
106+ it 'indexes the correct number of documents' do
107+ expect ( indexer . index ( docs ) ) . to eq 40
108+ end
109+ end
110+
99111 it 'commits changes to solr after indexing' do
100112 indexer . index ( docs )
101113 expect ( solr ) . to have_received ( :commit ) . once
You can’t perform that action at this time.
0 commit comments