Skip to content

Commit

Permalink
DEV-444: Explicitly commit documents when indexing (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
danschmidt5189 authored Jan 4, 2024
1 parent 5fc6048 commit 25a981f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions lib/gingr/solr_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def index_directory(directory)
Find.find(directory)
.select(&method(:json_file?))
.each(&method(:add))
@solr.commit
end

def update_reference_urls!(doc)
Expand Down
13 changes: 6 additions & 7 deletions spec/solr_indexer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,14 @@

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

indexer = Gingr::SolrIndexer.new
indexer.index_directory('directory')
expect(indexer).to have_received(:add).with('bar.json')
expect(indexer).to have_received(:add).with('baz.json')
expect(indexer).not_to have_received(:add).with('foo.xml')
solr = spy(RSolr::Client)
indexer = Gingr::SolrIndexer.new(solr)
indexer.index_directory('spec/fixture/jsonfile')
expect(indexer).to have_received(:add).with 'spec/fixture/jsonfile/actual-point.json'
expect(indexer).to have_received(:add).with 'spec/fixture/jsonfile/berkeley_public_pdf.json'
expect(solr).to have_received(:commit).once
end
end

Expand Down

0 comments on commit 25a981f

Please sign in to comment.