trabajo-afectivo/test/unit/notifiation_factory_test.rb

62 lines
1.6 KiB
Ruby
Raw Normal View History

# encoding: utf-8
require 'test_helper'
2014-05-27 13:22:21 +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,
: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,
)
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',
:string => '\'i18n(#{ticket.state.name})\' ticket state',
:result => '\'neu\' ticket state',
},
]
tests.each { |test|
result = NotificationFactory.build(
:string => test[:string],
:objects => {
2014-05-27 13:22:21 +00:00
:ticket => ticket,
:recipient => User.find(2),
},
:locale => test[:locale]
)
assert_equal( result, test[:result], "verify result" )
}
2014-05-27 13:22:21 +00:00
ticket.destroy
end
end