has_collection_update_spec.rb 1.0 KB

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