So not set pending reminder online notifications to seen.

This commit is contained in:
Martin Edenhofer 2016-02-20 14:09:56 +01:00
parent 77fedbe108
commit 08bd5186b7
3 changed files with 19 additions and 4 deletions

View file

@ -145,6 +145,7 @@ class Observer::Ticket::Notification::BackgroundJob
# delete old notifications
if @p[:type] == 'reminder_reached' || @p[:type] == 'escalation'
seen = false
OnlineNotification.remove_by_type('Ticket', ticket.id, @p[:type])
end
OnlineNotification.add(

View file

@ -278,13 +278,16 @@ returns
=end
def online_notification_seen_state(user_id_check = nil)
# always to set unseen for ticket owner
return false if user_id_check && user_id_check == owner_id && user_id_check != updated_by_id
state = Ticket::State.lookup(id: state_id)
state_type = Ticket::StateType.lookup(id: state.state_type_id)
# always to set unseen for ticket owner
if state_type.name != 'merged'
if user_id_check
return false if user_id_check == owner_id && user_id_check != updated_by_id
end
end
# set all to seen if pending action state is a closed or merged state
if state_type.name == 'pending action' && state.next_state_id
state = Ticket::State.lookup(id: state.next_state_id)

View file

@ -427,6 +427,17 @@ class OnlineNotificationTest < ActiveSupport::TestCase
assert_equal(ticket1.online_notification_seen_state(agent_user1.id), true)
assert_equal(ticket1.online_notification_seen_state(agent_user2.id), true)
# to closed by owner self, all to seen
ticket1.update_attributes(
owner_id: agent_user1.id,
state: Ticket::State.lookup(name: 'merged'),
updated_by_id: agent_user2.id,
)
assert_equal(ticket1.online_notification_seen_state, true)
assert_equal(ticket1.online_notification_seen_state(agent_user1.id), true)
assert_equal(ticket1.online_notification_seen_state(agent_user2.id), true)
end
def notification_check(online_notifications, checks)