has_search_index_backend_examples.rb 765 B

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