trabajo-afectivo/spec/models/concerns/has_search_index_backend_examples.rb
Thorsten Eckel ca56de3648 Maintenance: Updated to Rails 6.0.4 and the new Zeitwerk autoloader.
This changes the minimum supported version of PostgreSQL to 9.3.
2021-06-23 11:35:27 +00:00

36 lines
866 B
Ruby

# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
RSpec.shared_examples 'HasSearchIndexBackend' do |indexed_factory:|
describe '#search_index_update', performs_jobs: true do
subject { create(indexed_factory) }
before do
allow(SearchIndexBackend).to receive(:enabled?).and_return(true)
end
describe 'record indexing' do
before do
expect(subject).to be_present
end
it 'indexes on create' do
expect(SearchIndexAssociationsJob).to have_been_enqueued
end
it 'indexes on update' do
clear_jobs
subject.update(note: 'Updated')
expect(SearchIndexAssociationsJob).to have_been_enqueued
end
it 'indexes on touch' do
clear_jobs
subject.touch
expect(SearchIndexJob).to have_been_enqueued
end
end
end
end