Only set online notifications to seen for non ticket owners.
This commit is contained in:
parent
7c46db4be4
commit
77fedbe108
2 changed files with 31 additions and 5 deletions
|
@ -278,13 +278,17 @@ returns
|
|||
=end
|
||||
|
||||
def online_notification_seen_state(user_id_check = nil)
|
||||
state = Ticket::State.lookup( id: state_id )
|
||||
state_type = Ticket::StateType.lookup( id: state.state_type_id )
|
||||
|
||||
# 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)
|
||||
|
||||
# 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 )
|
||||
state_type = Ticket::StateType.lookup( id: state.state_type_id )
|
||||
state = Ticket::State.lookup(id: state.next_state_id)
|
||||
state_type = Ticket::StateType.lookup(id: state.state_type_id)
|
||||
end
|
||||
|
||||
# set all to seen if new state is pending reminder state
|
||||
|
|
|
@ -391,7 +391,7 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
|||
)
|
||||
|
||||
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_user1.id), false)
|
||||
assert_equal(ticket1.online_notification_seen_state(agent_user2.id), true)
|
||||
|
||||
# to open, all to seen
|
||||
|
@ -405,6 +405,28 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
|||
assert_equal(ticket1.online_notification_seen_state(agent_user1.id), false)
|
||||
assert_equal(ticket1.online_notification_seen_state(agent_user2.id), false)
|
||||
|
||||
# to closed, all only others to seen
|
||||
ticket1.update_attributes(
|
||||
owner_id: agent_user1.id,
|
||||
state: Ticket::State.lookup(name: 'closed'),
|
||||
updated_by_id: agent_user2.id,
|
||||
)
|
||||
|
||||
assert_equal(ticket1.online_notification_seen_state, true)
|
||||
assert_equal(ticket1.online_notification_seen_state(agent_user1.id), false)
|
||||
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: 'closed'),
|
||||
updated_by_id: agent_user1.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)
|
||||
|
|
Loading…
Reference in a new issue