Fixes #2931 - Pending reminder notifications are not sent if ticket is opened in tab

This commit is contained in:
Mantas Masalskis 2021-09-06 17:43:29 +02:00 committed by Thorsten Eckel
parent 380aa01643
commit 5a47caab33
4 changed files with 81 additions and 3 deletions

View File

@ -432,7 +432,19 @@ class App.TicketZoom extends App.Controller
@scrollHeaderPos = scroll
pendingTimeReminderReached: =>
App.TaskManager.touch(@taskKey)
setPendingTimeReminderDelay: =>
stateType = App.TicketStateType.find @ticket?.state?.state_type_id
return if stateType?.name != 'pending reminder'
delay = new Date(@ticket.pending_time) - new Date()
@delay @pendingTimeReminderReached, delay, 'pendingTimeReminderDelay'
render: (local) =>
@setPendingTimeReminderDelay()
# update taskbar with new meta data
App.TaskManager.touch(@taskKey)

View File

@ -152,8 +152,12 @@ class App.OnlineNotificationWidget extends App.Controller
)
fetch: =>
load = =>
load = (objects) =>
for elem in objects
App.TaskManager.touch "#{elem.object}-#{elem.o_id}"
@fetchedData = true
App.OnlineNotification.fetchFull(load, clear: true, force: true)
toggle: =>

View File

@ -5,8 +5,7 @@ module Ticket::ResetsPendingTimeSeconds
extend ActiveSupport::Concern
included do
before_create :ticket_reset_pending_time_seconds
before_update :ticket_reset_pending_time_seconds
before_save :ticket_reset_pending_time_seconds
end
private

View File

@ -0,0 +1,63 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require 'rails_helper'
RSpec.describe 'Online notification', type: :system do
let(:session_user) { User.find_by(login: 'admin@example.com') }
describe 'circle after pending reached' do
around do |example|
Ticket.without_callback :save, :before, :ticket_reset_pending_time_seconds do
example.run
end
end
context 'when pending time is reached soon' do
before do
visit "ticket/zoom/#{ticket.id}"
end
let(:ticket) { create(:ticket, owner: session_user, group: Group.first, state_name: 'pending reminder', pending_time: 4.seconds.from_now) }
it 'loads as pending ticket' do
expect(page).to have_css('.icon.pending')
end
it 'switches to open ticket' do
expect(page).to have_css('.icon.open')
end
context 'when time is reached in non-active tab' do
before { visit 'dashboard' }
it 'loads as pending ticket' do
expect(page).to have_css('.icon.pending')
end
it 'switches to open ticket' do
expect(page).to have_css('.icon.open')
end
end
end
context 'when pending time is set to reached soon to an open ticket' do
before do
ensure_websocket do
visit "ticket/zoom/#{ticket.id}"
end
ticket.update! state: Ticket::State.lookup(name: 'pending reminder'), pending_time: 5.seconds.from_now
end
let(:ticket) { create(:ticket, owner: session_user, group: Group.first) }
it 'loads as pending ticket' do
expect(page).to have_css('.icon.pending')
end
it 'switches to open ticket' do
expect(page).to have_css('.icon.open')
end
end
end
end