checks_kb_client_notification_examples.rb 1.7 KB

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