Check if online notifications are deleted after ticket destroy.
This commit is contained in:
parent
95ad1ff355
commit
11edfc8780
3 changed files with 46 additions and 11 deletions
|
@ -106,6 +106,34 @@ return all online notifications of an user
|
|||
|
||||
=begin
|
||||
|
||||
return all online notifications of an object
|
||||
|
||||
notifications = OnlineNotification.by_object( 'Ticket', 123 )
|
||||
|
||||
=end
|
||||
|
||||
def self.by_object( object_name, o_id )
|
||||
object_id = ObjectLookup.by_name( object_name )
|
||||
notifications = OnlineNotification.where(
|
||||
:object_lookup_id => object_id,
|
||||
:o_id => o_id,
|
||||
).
|
||||
order( 'created_at DESC, id DESC' ).
|
||||
limit( 10_000 )
|
||||
list = []
|
||||
notifications.each do |item|
|
||||
data = item.attributes
|
||||
data['object'] = ObjectLookup.by_id( data['object_lookup_id'] )
|
||||
data['type'] = TypeLookup.by_id( data['type_lookup_id'] )
|
||||
data.delete('object_lookup_id')
|
||||
data.delete('type_lookup_id')
|
||||
list.push data
|
||||
end
|
||||
list
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
return all online notifications of an user with assets
|
||||
|
||||
OnlineNotification.list_full( user )
|
||||
|
|
|
@ -213,6 +213,9 @@ returns
|
|||
|
||||
# delete articles
|
||||
self.articles.destroy_all
|
||||
|
||||
# destroy online notifications
|
||||
OnlineNotification.remove( self.class.to_s, self.id )
|
||||
end
|
||||
|
||||
end
|
|
@ -118,6 +118,10 @@ class OnlineNotificationTest < ActiveSupport::TestCase
|
|||
ticket.destroy
|
||||
found = Ticket.where( :id => ticket_id ).first
|
||||
assert( !found, "Ticket destroyed")
|
||||
|
||||
# check if notifications for ticket still exist
|
||||
notifications = OnlineNotification.by_object( 'Ticket', ticket_id )
|
||||
assert( notifications.empty?, "still notifications for destroyed ticket available")
|
||||
}
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue