Do not send notifications of article update / only on article create.

This commit is contained in:
Martin Edenhofer 2015-02-10 13:37:47 +01:00
parent 6cffb8c576
commit 675a6d1d0c
2 changed files with 42 additions and 0 deletions

View file

@ -128,6 +128,9 @@ class Observer::Ticket::Notification < ActiveRecord::Observer
# return if we run import mode
return if Setting.get('import_mode')
# ignore updates on articles / we just want send notifications on ticket updates
return if record.class.name == 'Ticket::Article'
# ignore certain attributes
real_changes = {}
record.changes.each {|key, value|

View file

@ -288,6 +288,20 @@ class TicketNotificationTest < ActiveSupport::TestCase
assert_equal( 0, notification_check(ticket3, agent2), ticket3.id )
# update article / not notification should be sent
article_inbound.internal = true
article_inbound.save
# execute ticket events
Observer::Ticket::Notification.transaction
#puts Delayed::Job.all.inspect
Delayed::Worker.new.work_off
# verify notifications not to agent1 and not to agent2
assert_equal( 2, notification_check(ticket3, agent1), ticket3.id )
assert_equal( 0, notification_check(ticket3, agent2), ticket3.id )
delete = ticket1.destroy
assert( delete, "ticket1 destroy" )
@ -472,6 +486,31 @@ class TicketNotificationTest < ActiveSupport::TestCase
assert_match( /2 normal/, body )
assert_match( /aktualis/, body )
bg = Observer::Ticket::Notification::BackgroundJob.new(
:ticket_id => ticket1.id,
:article_id => article.id,
:type => 'update',
:changes => {
:title => ['some notification template test 1', 'some notification template test 1 #2'],
:priority_id => [2, 3],
},
)
human_changes = bg.human_changes(agent1,ticket1)
puts "hc #{human_changes.inspect}"
human_changes = bg.human_changes(agent2,ticket1)
puts "hc2 #{human_changes.inspect}"
template = bg.template_update(agent1, ticket1, article, human_changes)
puts "t1 #{template.inspect}"
template = bg.template_update(agent2, ticket1, article, human_changes)
puts "t2 #{template.inspect}"
end
def notification_check(ticket, recipient)