has_search_index_backend_examples.rb 867 B

1234567891011121314151617181920212223242526272829303132333435
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. RSpec.shared_examples 'HasSearchIndexBackend' do |indexed_factory:|
  3. describe '#search_index_update', performs_jobs: true do
  4. subject { create(indexed_factory) }
  5. before do
  6. allow(SearchIndexBackend).to receive(:enabled?).and_return(true)
  7. end
  8. describe 'record indexing' do
  9. before do
  10. expect(subject).to be_present
  11. end
  12. it 'indexes on create' do
  13. expect(SearchIndexAssociationsJob).to have_been_enqueued
  14. end
  15. it 'indexes on update' do
  16. clear_jobs
  17. subject.update(note: 'Updated')
  18. expect(SearchIndexAssociationsJob).to have_been_enqueued
  19. end
  20. it 'indexes on touch' do
  21. clear_jobs
  22. subject.touch
  23. expect(SearchIndexJob).to have_been_enqueued
  24. end
  25. end
  26. end
  27. end