Check if online notifications are deleted after ticket destroy.

This commit is contained in:
Martin Edenhofer 2015-04-01 13:14:46 +02:00
parent 95ad1ff355
commit 11edfc8780
3 changed files with 46 additions and 11 deletions

View file

@ -51,8 +51,8 @@ mark online notification as seen
OnlineNotification.seen(
:id => 2,
:user => UserObject, #optional, if passed all
#notfications for the given user are marked as seen
:user => UserObject, # optional, if passed all
# notfications for the given user are marked as seen
)
=end
@ -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 )

View file

@ -213,6 +213,9 @@ returns
# delete articles
self.articles.destroy_all
# destroy online notifications
OnlineNotification.remove( self.class.to_s, self.id )
end
end

View file

@ -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