reset_notifications_preferences_job_spec.rb 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe ResetNotificationsPreferencesJob do
  4. let(:agent) { create(:agent) }
  5. before { agent }
  6. describe '#perform' do
  7. it 'resets notifications preferences on agents' do
  8. allow(User).to receive(:reset_notifications_preferences!)
  9. described_class.perform_now
  10. expect(User).to have_received(:reset_notifications_preferences!).with(agent)
  11. end
  12. it 'broadcasts message when operation is done' do
  13. allow(Sessions).to receive(:send_to)
  14. described_class.perform_now(send_to_when_done: 123)
  15. expect(Sessions)
  16. .to have_received(:send_to)
  17. .with(123, { event: 'ticket_agent_default_notifications_applied' })
  18. end
  19. end
  20. describe '#users_scope' do
  21. let(:customer) { create(:customer) }
  22. let(:agent_customer) { create(:agent_and_customer) }
  23. before { customer && agent_customer }
  24. it 'returns agents and agent-customers only' do
  25. expect(described_class.new.send(:users_scope)).to eq([agent, agent_customer])
  26. end
  27. end
  28. end