has_ticket_create_screen_impact_examples.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. RSpec.shared_examples 'HasTicketCreateScreenImpact' do |create_screen_factory:|
  2. describe '#push_ticket_create_screen', performs_jobs: true do
  3. subject { create(create_screen_factory) }
  4. context 'creating a record' do
  5. it 'enqueues a TicketCreateScreenJob job' do
  6. expect { subject }.to have_enqueued_job(TicketCreateScreenJob)
  7. end
  8. end
  9. context 'record exists' do
  10. before do
  11. subject
  12. clear_jobs
  13. end
  14. context 'attribute updated' do
  15. context 'name' do
  16. it 'enqueues a TicketCreateScreenJob job' do
  17. expect do
  18. subject.name = 'New name'
  19. subject.save!
  20. end.to have_enqueued_job(TicketCreateScreenJob)
  21. end
  22. end
  23. context 'updated_at' do
  24. it 'enqueues a TicketCreateScreenJob job' do
  25. expect { subject.touch }.to have_enqueued_job(TicketCreateScreenJob)
  26. end
  27. end
  28. end
  29. context 'record is deleted' do
  30. it 'enqueues a TicketCreateScreenJob job' do
  31. expect { subject.destroy! }.to have_enqueued_job(TicketCreateScreenJob)
  32. end
  33. end
  34. end
  35. end
  36. end