fix(object_id): Actually check for index .empty? instead of exist
This commit is contained in:
parent
f0e120b264
commit
e5b2588f45
@ -142,10 +142,9 @@ module Jekyll
|
|||||||
def self.remote_object_ids
|
def self.remote_object_ids
|
||||||
Logger.log('I:Getting list of existing records')
|
Logger.log('I:Getting list of existing records')
|
||||||
|
|
||||||
# No main index, the list is empty no matter what (we don't use the
|
# Main index empty, the list is empty no matter what (we don't use the
|
||||||
# dedicated index in that case)
|
# dedicated index in that case)
|
||||||
has_index = index_exist?(index)
|
return [] if record_count(index).zero?
|
||||||
return [] unless has_index
|
|
||||||
|
|
||||||
# Fast version, using the dedicated index
|
# Fast version, using the dedicated index
|
||||||
has_object_id_index = index_exist?(index_object_ids)
|
has_object_id_index = index_exist?(index_object_ids)
|
||||||
|
|||||||
@ -84,10 +84,10 @@ describe('storing object ids') do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'deleting the main index should force its recreation' do
|
describe 'clearing the main index should force its recreation' do
|
||||||
before do
|
before do
|
||||||
indexer.update_records(records)
|
indexer.update_records(records)
|
||||||
indexer.index.delete_index!
|
indexer.index.clear_index!
|
||||||
indexer.update_records(records)
|
indexer.update_records(records)
|
||||||
@index = indexer.index
|
@index = indexer.index
|
||||||
end
|
end
|
||||||
|
|||||||
@ -287,41 +287,41 @@ describe(Jekyll::Algolia::Indexer) do
|
|||||||
allow(current).to receive(:index_object_ids).and_return('dedicated_index')
|
allow(current).to receive(:index_object_ids).and_return('dedicated_index')
|
||||||
allow(current).to receive(:index).and_return('main_index')
|
allow(current).to receive(:index).and_return('main_index')
|
||||||
allow(current)
|
allow(current)
|
||||||
.to receive(:index_exist?)
|
.to receive(:record_count)
|
||||||
.with('main_index')
|
.with('main_index')
|
||||||
.and_return(main_index_exist)
|
.and_return(main_record_count)
|
||||||
allow(current)
|
allow(current)
|
||||||
.to receive(:index_exist?)
|
.to receive(:index_exist?)
|
||||||
.with('dedicated_index')
|
.with('dedicated_index')
|
||||||
.and_return(dedicated_index_exist)
|
.and_return(dedicated_index_exist)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'no index exists' do
|
describe 'no index is available' do
|
||||||
let(:main_index_exist) { false }
|
let(:main_record_count) { 0 }
|
||||||
let(:dedicated_index_exist) { false }
|
let(:dedicated_index_exist) { false }
|
||||||
it 'should return an empty list' do
|
it 'should return an empty list' do
|
||||||
should eq []
|
should eq []
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'only main index exists' do
|
describe 'only main index is available' do
|
||||||
let(:main_index_exist) { true }
|
let(:main_record_count) { 42 }
|
||||||
let(:dedicated_index_exist) { false }
|
let(:dedicated_index_exist) { false }
|
||||||
it 'should get objectIds from it' do
|
it 'should get objectIds from it' do
|
||||||
should eq 'main_results'
|
should eq 'main_results'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'only dedicated index exists' do
|
describe 'main index is unavailable' do
|
||||||
let(:main_index_exist) { false }
|
let(:main_record_count) { 0 }
|
||||||
let(:dedicated_index_exist) { true }
|
let(:dedicated_index_exist) { true }
|
||||||
it 'should not use objectIDs from it' do
|
it 'should not use objectIDs from it' do
|
||||||
should eq []
|
should eq []
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'both index exist' do
|
describe 'both index are available' do
|
||||||
let(:main_index_exist) { true }
|
let(:main_record_count) { 42 }
|
||||||
let(:dedicated_index_exist) { true }
|
let(:dedicated_index_exist) { true }
|
||||||
it 'should use objectIDs from the dedicated index' do
|
it 'should use objectIDs from the dedicated index' do
|
||||||
should eq 'dedicated_results'
|
should eq 'dedicated_results'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user