Improved notification tests.
This commit is contained in:
parent
de92c4a816
commit
e5a9dc8b78
3 changed files with 56 additions and 14 deletions
|
@ -177,7 +177,7 @@ returns:
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
if item.data_option
|
if item.data_option
|
||||||
data = data.merge( item.data_option )
|
data = data.merge( item.data_option.symbolize_keys )
|
||||||
end
|
end
|
||||||
attributes.push data
|
attributes.push data
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,10 +136,16 @@ class Observer::Ticket::Notification::BackgroundJob
|
||||||
|
|
||||||
# only show allowed attributes
|
# only show allowed attributes
|
||||||
attribute_list = ObjectManager::Attribute.by_object_as_hash('Ticket', user)
|
attribute_list = ObjectManager::Attribute.by_object_as_hash('Ticket', user)
|
||||||
|
#puts "AL #{attribute_list.inspect}"
|
||||||
user_related_changes = {}
|
user_related_changes = {}
|
||||||
@changes.each {|key,value|
|
@changes.each {|key, value|
|
||||||
#user_related_changes[key] = value
|
|
||||||
if attribute_list[key.to_s]
|
# if no config exists, use all attributes
|
||||||
|
if !attribute_list || attribute_list.empty?
|
||||||
|
user_related_changes[key] = value
|
||||||
|
|
||||||
|
# if config exists, just use existing attributes for user
|
||||||
|
elsif attribute_list[key.to_s]
|
||||||
user_related_changes[key] = value
|
user_related_changes[key] = value
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
@ -212,7 +218,7 @@ class Observer::Ticket::Notification::BackgroundJob
|
||||||
subject = 'Neues Ticket (#{ticket.title})'
|
subject = 'Neues Ticket (#{ticket.title})'
|
||||||
body = 'Hallo #{recipient.firstname},
|
body = 'Hallo #{recipient.firstname},
|
||||||
|
|
||||||
es wurde ein neues Ticket (#{ticket.title}) von #{ticket.updated_by.fullname} erstellt.
|
es wurde ein neues Ticket (#{ticket.title}) von "#{ticket.updated_by.fullname}" erstellt.
|
||||||
|
|
||||||
Gruppe: #{ticket.group.name}
|
Gruppe: #{ticket.group.name}
|
||||||
Besitzer: #{ticket.owner.fullname}
|
Besitzer: #{ticket.owner.fullname}
|
||||||
|
@ -226,7 +232,7 @@ Status: i18n(#{ticket.state.name})
|
||||||
subject = 'New Ticket (#{ticket.title})'
|
subject = 'New Ticket (#{ticket.title})'
|
||||||
body = 'Hi #{recipient.firstname},
|
body = 'Hi #{recipient.firstname},
|
||||||
|
|
||||||
a new Ticket (#{ticket.title}) has been created by #{ticket.updated_by.fullname}.
|
a new Ticket (#{ticket.title}) has been created by "#{ticket.updated_by.fullname}".
|
||||||
|
|
||||||
Group: #{ticket.group.name}
|
Group: #{ticket.group.name}
|
||||||
Owner: #{ticket.owner.fullname}
|
Owner: #{ticket.owner.fullname}
|
||||||
|
@ -263,7 +269,7 @@ State: i18n(#{ticket.state.name})
|
||||||
subject = 'Ticket aktualisiert (#{ticket.title})'
|
subject = 'Ticket aktualisiert (#{ticket.title})'
|
||||||
body = 'Hallo #{recipient.firstname},
|
body = 'Hallo #{recipient.firstname},
|
||||||
|
|
||||||
Ticket (#{ticket.title}) wurde von #{ticket.updated_by.fullname} aktualisiert.
|
Ticket (#{ticket.title}) wurde von "#{ticket.updated_by.fullname}" aktualisiert.
|
||||||
|
|
||||||
Änderungen:
|
Änderungen:
|
||||||
' + changes + '
|
' + changes + '
|
||||||
|
@ -275,7 +281,7 @@ Ticket (#{ticket.title}) wurde von #{ticket.updated_by.fullname} aktualisiert.
|
||||||
subject = 'Updated Ticket (#{ticket.title})'
|
subject = 'Updated Ticket (#{ticket.title})'
|
||||||
body = 'Hi #{recipient.firstname},
|
body = 'Hi #{recipient.firstname},
|
||||||
|
|
||||||
Ticket (#{ticket.title}) has been updated by #{ticket.updated_by.fullname}.
|
Ticket (#{ticket.title}) has been updated by "#{ticket.updated_by.fullname}".
|
||||||
|
|
||||||
Changes:
|
Changes:
|
||||||
' + changes + '
|
' + changes + '
|
||||||
|
|
|
@ -365,22 +365,58 @@ class TicketNotificationTest < ActiveSupport::TestCase
|
||||||
:priority_id => [1, 2],
|
:priority_id => [1, 2],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# check changed attributes
|
||||||
human_changes = bg.human_changes(agent1,ticket1)
|
human_changes = bg.human_changes(agent1,ticket1)
|
||||||
assert_equal( '1 low', human_changes['priority'][0] )
|
assert( human_changes['Priority'], 'Check if attributes translated based on ObjectManager::Attribute' )
|
||||||
assert_equal( '2 normal', human_changes['priority'][1] )
|
assert_equal( '1 low', human_changes['Priority'][0] )
|
||||||
|
assert_equal( '2 normal', human_changes['Priority'][1] )
|
||||||
assert_not( human_changes['priority_id'] )
|
assert_not( human_changes['priority_id'] )
|
||||||
|
|
||||||
# en notification
|
# en template
|
||||||
template = bg.template_update(agent1, ticket1, article, human_changes)
|
template = bg.template_update(agent1, ticket1, article, human_changes)
|
||||||
assert( template[:subject] )
|
assert( template[:subject] )
|
||||||
assert( template[:body] )
|
assert( template[:body] )
|
||||||
puts template.inspect
|
assert_match( /Priority/, template[:body] )
|
||||||
|
assert_match( /1 low/, template[:body] )
|
||||||
|
assert_match( /3 normal/, template[:body] )
|
||||||
|
|
||||||
# de notification
|
# en notification
|
||||||
|
body = NotificationFactory.build(
|
||||||
|
:locale => agent1.preferences[:locale],
|
||||||
|
:string => template[:body],
|
||||||
|
:objects => {
|
||||||
|
:ticket => ticket1,
|
||||||
|
:article => article,
|
||||||
|
:recipient => agent1,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
assert_match( /Priority/, body )
|
||||||
|
assert_match( /1 low/, body )
|
||||||
|
assert_match( /3 normal/, body )
|
||||||
|
|
||||||
|
# de template
|
||||||
template = bg.template_update(agent2, ticket1, article, human_changes)
|
template = bg.template_update(agent2, ticket1, article, human_changes)
|
||||||
assert( template[:subject] )
|
assert( template[:subject] )
|
||||||
assert( template[:body] )
|
assert( template[:body] )
|
||||||
puts template.inspect
|
assert_match( /Priority/, template[:body] )
|
||||||
|
assert_match( /1 low/, template[:body] )
|
||||||
|
assert_match( /3 normal/, template[:body] )
|
||||||
|
|
||||||
|
# de notification
|
||||||
|
body = NotificationFactory.build(
|
||||||
|
:locale => agent2.preferences[:locale],
|
||||||
|
:string => template[:body],
|
||||||
|
:objects => {
|
||||||
|
:ticket => ticket1,
|
||||||
|
:article => article,
|
||||||
|
:recipient => agent2,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
assert_match( /Priorität/, body )
|
||||||
|
assert_match( /1 gering/, body )
|
||||||
|
assert_match( /3 normal/, body )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue