has_collection_update_spec.rb 982 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. require 'rails_helper'
  2. RSpec.describe HasCollectionUpdate, type: :job do
  3. context 'with groups' do
  4. let!(:group) { create(:group) }
  5. it 'create should enqueue no job' do
  6. collection_jobs = enqueued_jobs.select do |job|
  7. job[:job] == CollectionUpdateJob && job[:args][0] == 'Group'
  8. end
  9. expect(collection_jobs.count).to be(1)
  10. end
  11. context 'updating attribute' do
  12. before do
  13. clear_jobs
  14. end
  15. context 'name' do
  16. it 'enqueues a job' do
  17. expect { group.update!(name: 'new name') }.to have_enqueued_job(CollectionUpdateJob).with('Group')
  18. end
  19. end
  20. context 'updated_at' do
  21. it 'enqueues a job' do
  22. expect { group.touch }.to have_enqueued_job(CollectionUpdateJob).with('Group')
  23. end
  24. end
  25. end
  26. it 'delete should enqueue a job' do
  27. clear_jobs
  28. expect { group.destroy! }.to have_enqueued_job(CollectionUpdateJob).with('Group')
  29. end
  30. end
  31. end