notifiation_factory_test.rb 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # encoding: utf-8
  2. require 'test_helper'
  3. class NotificationFactoryTest < ActiveSupport::TestCase
  4. test 'notifications' do
  5. ticket = Ticket.create(
  6. :title => 'some title äöüß',
  7. :group => Group.lookup( :name => 'Users'),
  8. :customer_id => 2,
  9. :state => Ticket::State.lookup( :name => 'new' ),
  10. :priority => Ticket::Priority.lookup( :name => '2 normal' ),
  11. :updated_by_id => 1,
  12. :created_by_id => 1,
  13. )
  14. tests = [
  15. {
  16. :locale => 'en',
  17. :string => 'Hi #{recipient.firstname},',
  18. :result => 'Hi Nicole,',
  19. },
  20. {
  21. :locale => 'de',
  22. :string => 'Hi #{recipient.firstname},',
  23. :result => 'Hi Nicole,',
  24. },
  25. {
  26. :locale => 'de',
  27. :string => 'Hi #{recipient.firstname}, Group: #{ticket.group.name}',
  28. :result => 'Hi Nicole, Group: Users',
  29. },
  30. {
  31. :locale => 'de',
  32. :string => '#{config.http_type} some text',
  33. :result => 'http some text',
  34. },
  35. {
  36. :locale => 'de',
  37. :string => 'i18n(#{"New"}) some text',
  38. :result => 'Neu some text',
  39. },
  40. {
  41. :locale => 'de',
  42. :string => '\'i18n(#{ticket.state.name})\' ticket state',
  43. :result => '\'neu\' ticket state',
  44. },
  45. ]
  46. tests.each { |test|
  47. result = NotificationFactory.build(
  48. :string => test[:string],
  49. :objects => {
  50. :ticket => ticket,
  51. :recipient => User.find(2),
  52. },
  53. :locale => test[:locale]
  54. )
  55. assert_equal( result, test[:result], "verify result" )
  56. }
  57. ticket.destroy
  58. end
  59. end