2019-01-15 12:32:14 +00:00
|
|
|
RSpec.shared_examples 'HasSearchIndexBackend' do |indexed_factory:|
|
|
|
|
|
|
|
|
context '#search_index_update', performs_jobs: true do
|
|
|
|
subject { create(indexed_factory) }
|
|
|
|
|
2019-04-15 01:41:17 +00:00
|
|
|
before do
|
2019-01-15 12:32:14 +00:00
|
|
|
allow(SearchIndexBackend).to receive(:enabled?).and_return(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'record indexing' do
|
|
|
|
|
2019-04-15 01:41:17 +00:00
|
|
|
before do
|
2019-01-15 12:32:14 +00:00
|
|
|
expect(subject).to be_present
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'indexes on create' do
|
|
|
|
expect(SearchIndexJob).to have_been_enqueued
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'indexes on update' do
|
|
|
|
clear_jobs
|
|
|
|
subject.update(note: 'Updated')
|
|
|
|
expect(SearchIndexJob).to have_been_enqueued
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'indexes on touch' do
|
|
|
|
clear_jobs
|
|
|
|
subject.touch
|
|
|
|
expect(SearchIndexJob).to have_been_enqueued
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|