2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2019-01-15 12:32:14 +00:00
|
|
|
RSpec.shared_examples 'HasSearchIndexBackend' do |indexed_factory:|
|
|
|
|
|
2020-02-18 19:51:31 +00:00
|
|
|
describe '#search_index_update', performs_jobs: true do
|
2019-01-15 12:32:14 +00:00
|
|
|
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
|
|
|
|
|
2021-06-23 11:35:27 +00:00
|
|
|
describe 'record indexing' do
|
2019-01-15 12:32:14 +00:00
|
|
|
|
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
|
2021-05-18 07:50:28 +00:00
|
|
|
expect(SearchIndexAssociationsJob).to have_been_enqueued
|
2019-01-15 12:32:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'indexes on update' do
|
|
|
|
clear_jobs
|
|
|
|
subject.update(note: 'Updated')
|
2021-05-18 07:50:28 +00:00
|
|
|
expect(SearchIndexAssociationsJob).to have_been_enqueued
|
2019-01-15 12:32:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'indexes on touch' do
|
|
|
|
clear_jobs
|
|
|
|
subject.touch
|
|
|
|
expect(SearchIndexJob).to have_been_enqueued
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|