2013-01-04 14:28:55 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
require 'test_helper'
|
2014-05-27 13:22:21 +00:00
|
|
|
|
2013-01-04 14:28:55 +00:00
|
|
|
class NotificationFactoryTest < ActiveSupport::TestCase
|
|
|
|
test 'notifications' do
|
2014-05-27 13:22:21 +00:00
|
|
|
ticket = Ticket.create(
|
|
|
|
:title => 'some title äöüß',
|
|
|
|
:group => Group.lookup( :name => 'Users'),
|
|
|
|
:customer_id => 2,
|
2014-06-08 22:01:20 +00:00
|
|
|
:state => Ticket::State.lookup( :name => 'new' ),
|
|
|
|
:priority => Ticket::Priority.lookup( :name => '2 normal' ),
|
2014-05-27 13:22:21 +00:00
|
|
|
:updated_by_id => 1,
|
|
|
|
:created_by_id => 1,
|
|
|
|
)
|
|
|
|
|
2013-01-04 14:28:55 +00:00
|
|
|
tests = [
|
|
|
|
{
|
|
|
|
:locale => 'en',
|
|
|
|
:string => 'Hi #{recipient.firstname},',
|
|
|
|
:result => 'Hi Nicole,',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
:locale => 'de',
|
|
|
|
:string => 'Hi #{recipient.firstname},',
|
|
|
|
:result => 'Hi Nicole,',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
:locale => 'de',
|
|
|
|
:string => 'Hi #{recipient.firstname}, Group: #{ticket.group.name}',
|
|
|
|
:result => 'Hi Nicole, Group: Users',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
:locale => 'de',
|
|
|
|
:string => '#{config.http_type} some text',
|
|
|
|
:result => 'http some text',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
:locale => 'de',
|
|
|
|
:string => 'i18n(#{"New"}) some text',
|
|
|
|
:result => 'Neu some text',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
:locale => 'de',
|
2014-06-08 22:01:20 +00:00
|
|
|
:string => '\'i18n(#{ticket.state.name})\' ticket state',
|
2013-01-04 14:28:55 +00:00
|
|
|
:result => '\'neu\' ticket state',
|
|
|
|
},
|
|
|
|
]
|
|
|
|
tests.each { |test|
|
|
|
|
result = NotificationFactory.build(
|
|
|
|
:string => test[:string],
|
|
|
|
:objects => {
|
2014-05-27 13:22:21 +00:00
|
|
|
:ticket => ticket,
|
2013-01-04 14:28:55 +00:00
|
|
|
:recipient => User.find(2),
|
|
|
|
},
|
|
|
|
:locale => test[:locale]
|
|
|
|
)
|
|
|
|
assert_equal( result, test[:result], "verify result" )
|
|
|
|
}
|
2014-05-27 13:22:21 +00:00
|
|
|
|
|
|
|
ticket.destroy
|
2013-01-04 14:28:55 +00:00
|
|
|
end
|
|
|
|
end
|