diff --git a/app/models/observer/ticket/notification.rb b/app/models/observer/ticket/notification.rb index b3bc869b8..f07afc9da 100644 --- a/app/models/observer/ticket/notification.rb +++ b/app/models/observer/ticket/notification.rb @@ -17,10 +17,20 @@ class Observer::Ticket::Notification < ActiveRecord::Observer # get current state of objects if event[:name] == 'Ticket::Article' article = Ticket::Article.lookup( :id => event[:id] ) + + # next if article is already deleted + next if !article + ticket = article.ticket - else + elsif event[:name] == 'Ticket' ticket = Ticket.lookup( :id => event[:id] ) + + # next if ticket is already deleted + next if !ticket + article = ticket.articles[-1] + else + raise "unknown object for notification #{event[:name]}" end # send new ticket notification to agents diff --git a/test/unit/twitter_test.rb b/test/unit/twitter_test.rb index ee9fee0a9..e14d47807 100644 --- a/test/unit/twitter_test.rb +++ b/test/unit/twitter_test.rb @@ -150,7 +150,7 @@ class TwitterTest < ActiveSupport::TestCase text, ) assert( dm, "dm with ##{hash} created" ) - sleep 20 + sleep 10 # fetch check system account Channel.fetch