checks_kb_client_notification_examples.rb 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. RSpec.shared_examples 'ChecksKbClientNotification' do
  3. context 'sends client notifications', performs_jobs: true do
  4. before { subject }
  5. it 'on creation' do
  6. expect(ChecksKbClientNotificationJob).to have_been_enqueued.with(subject.class.name, subject.id)
  7. end
  8. context 'after initial notifications are cleared' do
  9. before { clear_jobs }
  10. it 'on update' do
  11. subject.update(updated_at: Time.zone.now)
  12. expect(ChecksKbClientNotificationJob).to have_been_enqueued.with(subject.class.name, subject.id)
  13. end
  14. it 'on touch' do
  15. subject.touch
  16. expect(ChecksKbClientNotificationJob).to have_been_enqueued.with(subject.class.name, subject.id)
  17. end
  18. it 'on destroy' do
  19. subject.destroy
  20. expect(ChecksKbClientNotificationJob).not_to have_been_enqueued.with(subject.class.name, subject.id)
  21. end
  22. it 'notifications be disabled' do
  23. ChecksKbClientNotification.disable_in_all_classes!
  24. subject.update(updated_at: Time.zone.now)
  25. expect(ChecksKbClientNotificationJob).not_to have_been_enqueued.at_least(:once) # some object have associations that triggers touch job after creation
  26. end
  27. it 'notifications be re-enabled' do
  28. ChecksKbClientNotification.disable_in_all_classes!
  29. ChecksKbClientNotification.enable_in_all_classes!
  30. subject.update(updated_at: Time.zone.now)
  31. expect(ChecksKbClientNotificationJob).to have_been_enqueued.at_least(:once) # some object have associations that triggers touch job after creation
  32. end
  33. end
  34. end
  35. end