feat(log): Do not delete an empty list of records

This commit is contained in:
Pixelastic 2017-11-29 17:09:39 +01:00
parent 3aacc6e2a5
commit 1f8ee17433
2 changed files with 12 additions and 0 deletions

View File

@ -75,6 +75,7 @@ module Jekyll
# #
# Does nothing in dry run mode # Does nothing in dry run mode
def self.delete_records_by_id(index, ids) def self.delete_records_by_id(index, ids)
return if ids.empty?
Logger.log("I:Deleting #{ids.length} records") Logger.log("I:Deleting #{ids.length} records")
return if Configurator.dry_run? return if Configurator.dry_run?

View File

@ -145,6 +145,17 @@ describe(Jekyll::Algolia::Indexer) do
.with(ids) .with(ids)
end end
end end
context 'when deleting zero records' do
let(:ids) { [] }
before do
allow(logger).to receive(:log)
end
it do
expect(logger).to_not have_received(:log)
expect(index).to_not have_received(:delete_objects!)
end
end
end end
describe '.remote_object_ids' do describe '.remote_object_ids' do