Skip to content

Commit 25a981f

Browse files
DEV-444: Explicitly commit documents when indexing (#19)
1 parent 5fc6048 commit 25a981f

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lib/gingr/solr_indexer.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def index_directory(directory)
3434
Find.find(directory)
3535
.select(&method(:json_file?))
3636
.each(&method(:add))
37+
@solr.commit
3738
end
3839

3940
def update_reference_urls!(doc)

spec/solr_indexer_spec.rb

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,14 @@
5050

5151
describe '#index_directory' do
5252
it 'adds all .json files to solr' do
53-
files = ['foo.xml', 'bar.json', 'baz.json'].shuffle
54-
expect(Find).to receive(:find).with('directory').and_return files
5553
Gingr::SolrIndexer.any_instance.stub(:add)
5654

57-
indexer = Gingr::SolrIndexer.new
58-
indexer.index_directory('directory')
59-
expect(indexer).to have_received(:add).with('bar.json')
60-
expect(indexer).to have_received(:add).with('baz.json')
61-
expect(indexer).not_to have_received(:add).with('foo.xml')
55+
solr = spy(RSolr::Client)
56+
indexer = Gingr::SolrIndexer.new(solr)
57+
indexer.index_directory('spec/fixture/jsonfile')
58+
expect(indexer).to have_received(:add).with 'spec/fixture/jsonfile/actual-point.json'
59+
expect(indexer).to have_received(:add).with 'spec/fixture/jsonfile/berkeley_public_pdf.json'
60+
expect(solr).to have_received(:commit).once
6261
end
6362
end
6463

0 commit comments

Comments
 (0)