Fixed issue #1920 - Sometimes notifications are note marked as seen if somebody else already closed the ticketed.
This commit is contained in:
parent
20e0784c34
commit
050f5527e6
5 changed files with 89 additions and 7 deletions
25
app/models/observer/ticket/escalation_update.rb
Normal file
25
app/models/observer/ticket/escalation_update.rb
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
|
class Observer::Ticket::EscalationUpdate < ActiveRecord::Observer
|
||||||
|
observe 'ticket'
|
||||||
|
|
||||||
|
def after_create(record)
|
||||||
|
_check(record)
|
||||||
|
end
|
||||||
|
|
||||||
|
def after_update(record)
|
||||||
|
_check(record)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def _check(record)
|
||||||
|
|
||||||
|
# return if we run import mode
|
||||||
|
return false if Setting.get('import_mode')
|
||||||
|
|
||||||
|
return false if !record.saved_changes?
|
||||||
|
|
||||||
|
record.escalation_calculation
|
||||||
|
end
|
||||||
|
end
|
|
@ -23,9 +23,7 @@ class Ticket < ApplicationModel
|
||||||
|
|
||||||
store :preferences
|
store :preferences
|
||||||
before_create :check_generate, :check_defaults, :check_title, :set_default_state, :set_default_priority
|
before_create :check_generate, :check_defaults, :check_title, :set_default_state, :set_default_priority
|
||||||
after_create :check_escalation_update
|
|
||||||
before_update :check_defaults, :check_title, :reset_pending_time, :check_owner_active
|
before_update :check_defaults, :check_title, :reset_pending_time, :check_owner_active
|
||||||
after_update :check_escalation_update
|
|
||||||
|
|
||||||
validates :group_id, presence: true
|
validates :group_id, presence: true
|
||||||
|
|
||||||
|
@ -1188,11 +1186,6 @@ result
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_escalation_update
|
|
||||||
escalation_calculation
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_default_state
|
def set_default_state
|
||||||
return true if state_id
|
return true if state_id
|
||||||
default_ticket_state = Ticket::State.find_by(default_create: true)
|
default_ticket_state = Ticket::State.find_by(default_create: true)
|
||||||
|
|
|
@ -35,6 +35,7 @@ module Zammad
|
||||||
'observer::_ticket::_ref_object_touch',
|
'observer::_ticket::_ref_object_touch',
|
||||||
'observer::_ticket::_online_notification_seen',
|
'observer::_ticket::_online_notification_seen',
|
||||||
'observer::_ticket::_stats_reopen',
|
'observer::_ticket::_stats_reopen',
|
||||||
|
'observer::_ticket::_escalation_update',
|
||||||
'observer::_tag::_ticket_history',
|
'observer::_tag::_ticket_history',
|
||||||
'observer::_user::_ref_object_touch',
|
'observer::_user::_ref_object_touch',
|
||||||
'observer::_user::_ticket_organization',
|
'observer::_user::_ticket_organization',
|
||||||
|
|
|
@ -35,6 +35,57 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
||||||
created_by_id: 1
|
created_by_id: 1
|
||||||
)
|
)
|
||||||
@customer_user = User.lookup(email: 'nicole.braun@zammad.org')
|
@customer_user = User.lookup(email: 'nicole.braun@zammad.org')
|
||||||
|
|
||||||
|
calendar1 = Calendar.create_or_update(
|
||||||
|
name: 'EU 1 - test',
|
||||||
|
timezone: 'Europe/Berlin',
|
||||||
|
business_hours: {
|
||||||
|
mon: {
|
||||||
|
active: true,
|
||||||
|
timeframes: [ ['00:00', '23:59'] ]
|
||||||
|
},
|
||||||
|
tue: {
|
||||||
|
active: true,
|
||||||
|
timeframes: [ ['00:00', '23:59'] ]
|
||||||
|
},
|
||||||
|
wed: {
|
||||||
|
active: true,
|
||||||
|
timeframes: [ ['00:00', '23:59'] ]
|
||||||
|
},
|
||||||
|
thu: {
|
||||||
|
active: true,
|
||||||
|
timeframes: [ ['00:00', '23:59'] ]
|
||||||
|
},
|
||||||
|
fri: {
|
||||||
|
active: true,
|
||||||
|
timeframes: [ ['00:00', '23:59'] ]
|
||||||
|
},
|
||||||
|
sat: {
|
||||||
|
active: true,
|
||||||
|
timeframes: [ ['00:00', '23:59'] ]
|
||||||
|
},
|
||||||
|
sun: {
|
||||||
|
active: true,
|
||||||
|
timeframes: [ ['00:00', '23:59'] ]
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: true,
|
||||||
|
ical_url: nil,
|
||||||
|
updated_by_id: 1,
|
||||||
|
created_by_id: 1,
|
||||||
|
)
|
||||||
|
|
||||||
|
sla1 = Sla.create_or_update(
|
||||||
|
name: 'test sla 1',
|
||||||
|
condition: {},
|
||||||
|
first_response_time: 20,
|
||||||
|
update_time: 60,
|
||||||
|
solution_time: 120,
|
||||||
|
calendar_id: calendar1.id,
|
||||||
|
updated_by_id: 1,
|
||||||
|
created_by_id: 1,
|
||||||
|
)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'ticket notification' do
|
test 'ticket notification' do
|
||||||
|
|
|
@ -114,12 +114,24 @@ class TicketEscalationTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
ticket.save!
|
ticket.save!
|
||||||
assert_not(ticket.has_changes_to_save?)
|
assert_not(ticket.has_changes_to_save?)
|
||||||
|
assert(ticket.escalation_at)
|
||||||
|
assert_equal(ticket_escalation_at.to_s, ticket.escalation_at.to_s)
|
||||||
|
|
||||||
|
ticket.title = 'some value 123-1'
|
||||||
|
ticket.save!
|
||||||
|
assert_not(ticket.has_changes_to_save?)
|
||||||
|
|
||||||
assert(ticket.escalation_at)
|
assert(ticket.escalation_at)
|
||||||
assert_not_equal(ticket_escalation_at.to_s, ticket.escalation_at.to_s)
|
assert_not_equal(ticket_escalation_at.to_s, ticket.escalation_at.to_s)
|
||||||
|
|
||||||
sla.destroy!
|
sla.destroy!
|
||||||
calendar.destroy!
|
calendar.destroy!
|
||||||
|
|
||||||
|
ticket.save!
|
||||||
|
assert_not(ticket.has_changes_to_save?)
|
||||||
|
assert(ticket.escalation_at)
|
||||||
|
|
||||||
|
ticket.title = 'some value 123-2'
|
||||||
ticket.save!
|
ticket.save!
|
||||||
assert_not(ticket.has_changes_to_save?)
|
assert_not(ticket.has_changes_to_save?)
|
||||||
assert_not(ticket.escalation_at)
|
assert_not(ticket.escalation_at)
|
||||||
|
|
Loading…
Reference in a new issue