2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2018-12-21 16:33:45 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe TicketOnlineNotificationSeenJob, type: :job do
|
|
|
|
let!(:user) { create(:user) }
|
|
|
|
let!(:other_user) { create(:user) }
|
|
|
|
let!(:ticket) { create(:ticket, owner: user, created_by_id: user.id) }
|
|
|
|
let!(:online_notification) do
|
|
|
|
create(:online_notification, o_id: ticket.id, user_id: user.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'checks if online notification has not been seen' do
|
|
|
|
expect(online_notification.reload.seen).to be false
|
|
|
|
end
|
|
|
|
|
2020-07-31 13:41:26 +00:00
|
|
|
it 'checks if online notification has been seen', current_user_id: -> { user.id } do
|
2018-12-21 16:33:45 +00:00
|
|
|
ticket.state_id = Ticket::State.lookup(name: 'closed').id
|
|
|
|
ticket.save!
|
|
|
|
|
|
|
|
expect do
|
2019-09-16 15:04:17 +00:00
|
|
|
described_class.perform_now(ticket.id, user.id)
|
2018-12-21 16:33:45 +00:00
|
|
|
end.to change { online_notification.reload.seen }
|
|
|
|
end
|
|
|
|
end
|