ticket_online_notification_seen_job_spec.rb 843 B

12345678910111213141516171819202122232425
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe TicketOnlineNotificationSeenJob, type: :job do
  4. let!(:user) { create(:user) }
  5. let!(:other_user) { create(:user) }
  6. let!(:ticket) { create(:ticket, owner: user, created_by_id: user.id) }
  7. let!(:online_notification) do
  8. create(:online_notification, o_id: ticket.id, user_id: user.id)
  9. end
  10. it 'checks if online notification has not been seen' do
  11. expect(online_notification.reload.seen).to be false
  12. end
  13. it 'checks if online notification has been seen', current_user_id: -> { user.id } do
  14. ticket.state_id = Ticket::State.lookup(name: 'closed').id
  15. ticket.save!
  16. expect do
  17. described_class.perform_now(ticket.id, user.id)
  18. end.to change { online_notification.reload.seen }
  19. end
  20. end