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
|
2016-01-18 01:35:07 +00:00
|
|
|
|
|
|
|
Translation.load('de-de')
|
|
|
|
|
2015-01-07 12:11:30 +00:00
|
|
|
test 'notifications send' do
|
|
|
|
result = NotificationFactory.send(
|
2015-04-27 13:42:53 +00:00
|
|
|
recipient: User.find(2),
|
|
|
|
subject: 'sime subject',
|
|
|
|
body: 'some body',
|
|
|
|
content_type: '',
|
2015-01-07 12:11:30 +00:00
|
|
|
)
|
|
|
|
assert_match('some body', result.to_s)
|
|
|
|
assert_match('text/plain', result.to_s)
|
|
|
|
assert_no_match('text/html', result.to_s)
|
|
|
|
|
|
|
|
result = NotificationFactory.send(
|
2015-04-27 13:42:53 +00:00
|
|
|
recipient: User.find(2),
|
|
|
|
subject: 'sime subject',
|
|
|
|
body: 'some body',
|
|
|
|
content_type: 'text/plain',
|
2015-01-07 12:11:30 +00:00
|
|
|
)
|
|
|
|
assert_match('some body', result.to_s)
|
|
|
|
assert_match('text/plain', result.to_s)
|
|
|
|
assert_no_match('text/html', result.to_s)
|
|
|
|
|
|
|
|
result = NotificationFactory.send(
|
2015-04-27 13:42:53 +00:00
|
|
|
recipient: User.find(2),
|
|
|
|
subject: 'sime subject',
|
|
|
|
body: 'some <span>body</span>',
|
|
|
|
content_type: 'text/html',
|
2015-01-07 12:11:30 +00:00
|
|
|
)
|
|
|
|
assert_match('some body', result.to_s)
|
|
|
|
assert_match('text/plain', result.to_s)
|
|
|
|
assert_match('<span>body</span>', result.to_s)
|
|
|
|
assert_match('text/html', result.to_s)
|
|
|
|
end
|
|
|
|
|
2014-12-28 13:02:23 +00:00
|
|
|
test 'notifications base' do
|
2014-05-27 13:22:21 +00:00
|
|
|
ticket = Ticket.create(
|
2015-04-27 13:42:53 +00:00
|
|
|
title: 'some title äöüß',
|
|
|
|
group: Group.lookup( name: 'Users'),
|
|
|
|
customer_id: 2,
|
|
|
|
state: Ticket::State.lookup( name: 'new' ),
|
|
|
|
priority: Ticket::Priority.lookup( name: '2 normal' ),
|
|
|
|
updated_by_id: 2,
|
|
|
|
created_by_id: 2,
|
2014-12-28 13:02:23 +00:00
|
|
|
)
|
|
|
|
article_plain = Ticket::Article.create(
|
2015-04-27 13:42:53 +00:00
|
|
|
ticket_id: ticket.id,
|
|
|
|
type_id: Ticket::Article::Type.where(name: 'phone' ).first.id,
|
|
|
|
sender_id: Ticket::Article::Sender.where(name: 'Customer' ).first.id,
|
|
|
|
from: 'Zammad Feedback <feedback@example.org>',
|
|
|
|
body: 'some text',
|
|
|
|
internal: false,
|
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
2014-05-27 13:22:21 +00:00
|
|
|
)
|
2013-01-04 14:28:55 +00:00
|
|
|
tests = [
|
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'en',
|
|
|
|
string: 'Hi #{recipient.firstname},',
|
|
|
|
result: 'Hi Nicole,',
|
2013-01-04 14:28:55 +00:00
|
|
|
},
|
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
string: 'Hi #{recipient.firstname},',
|
|
|
|
result: 'Hi Nicole,',
|
2013-01-04 14:28:55 +00:00
|
|
|
},
|
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
string: 'Hi #{recipient.firstname}, Group: #{ticket.group.name}',
|
|
|
|
result: 'Hi Nicole, Group: Users',
|
2013-01-04 14:28:55 +00:00
|
|
|
},
|
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
string: '#{config.http_type} some text',
|
|
|
|
result: 'http some text',
|
2013-01-04 14:28:55 +00:00
|
|
|
},
|
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
string: 'i18n(New) some text',
|
|
|
|
result: 'Neu some text',
|
2013-01-04 14:28:55 +00:00
|
|
|
},
|
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
string: '\'i18n(#{ticket.state.name})\' ticket state',
|
|
|
|
result: '\'neu\' ticket state',
|
2013-01-04 14:28:55 +00:00
|
|
|
},
|
2015-01-02 22:34:37 +00:00
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
string: 'a #{not_existing_object.test}',
|
|
|
|
result: 'a #{not_existing_object / no such object}',
|
2015-01-02 22:34:37 +00:00
|
|
|
},
|
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
string: 'a #{ticket.level1}',
|
|
|
|
result: 'a #{ticket.level1 / no such method}',
|
2015-01-02 22:34:37 +00:00
|
|
|
},
|
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
string: 'a #{ticket.level1.level2}',
|
|
|
|
result: 'a #{ticket.level1 / no such method}',
|
2015-01-02 22:34:37 +00:00
|
|
|
},
|
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
string: 'a #{ticket.title.level2}',
|
|
|
|
result: 'a #{ticket.title.level2 / no such method}',
|
2015-01-02 22:34:37 +00:00
|
|
|
},
|
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
string: 'by #{ticket.updated_by.fullname}',
|
|
|
|
result: 'by Nicole Braun',
|
2015-01-02 22:34:37 +00:00
|
|
|
},
|
2014-12-28 13:02:23 +00:00
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
string: 'Subject #{article.from}, Group: #{ticket.group.name}',
|
|
|
|
result: 'Subject Zammad Feedback <feedback@example.org>, Group: Users',
|
2014-12-28 13:02:23 +00:00
|
|
|
},
|
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
string: 'Body #{article.body}, Group: #{ticket.group.name}',
|
|
|
|
result: 'Body some text, Group: Users',
|
2014-12-28 13:02:23 +00:00
|
|
|
},
|
2014-10-19 18:26:01 +00:00
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
string: '\#{puts `ls`}',
|
|
|
|
result: '\#{puts `ls`} (not allowed)',
|
2014-10-19 18:26:01 +00:00
|
|
|
},
|
2015-02-10 14:59:21 +00:00
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
string: 'test i18n(new)',
|
|
|
|
result: 'test neu',
|
2015-02-10 14:59:21 +00:00
|
|
|
},
|
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
string: 'test i18n()',
|
|
|
|
result: 'test ',
|
2015-02-10 14:59:21 +00:00
|
|
|
},
|
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
string: 'test i18n(new) i18n(open)',
|
|
|
|
result: 'test neu offen',
|
2015-02-10 14:59:21 +00:00
|
|
|
},
|
2013-01-04 14:28:55 +00:00
|
|
|
]
|
|
|
|
tests.each { |test|
|
|
|
|
result = NotificationFactory.build(
|
2015-04-27 13:42:53 +00:00
|
|
|
string: test[:string],
|
|
|
|
objects: {
|
|
|
|
ticket: ticket,
|
|
|
|
article: article_plain,
|
|
|
|
recipient: User.find(2),
|
2014-12-28 13:02:23 +00:00
|
|
|
},
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: test[:locale]
|
2014-12-28 13:02:23 +00:00
|
|
|
)
|
2015-04-27 12:51:43 +00:00
|
|
|
assert_equal( test[:result], result, 'verify result' )
|
2014-12-28 13:02:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ticket.destroy
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'notifications html' do
|
|
|
|
ticket = Ticket.create(
|
2015-04-27 13:42:53 +00:00
|
|
|
title: 'some title <b>äöüß</b> 2',
|
|
|
|
group: Group.lookup( name: 'Users'),
|
|
|
|
customer_id: 2,
|
|
|
|
state: Ticket::State.lookup( name: 'new' ),
|
|
|
|
priority: Ticket::Priority.lookup( name: '2 normal' ),
|
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
2014-12-28 13:02:23 +00:00
|
|
|
)
|
|
|
|
article_html = Ticket::Article.create(
|
2015-04-27 13:42:53 +00:00
|
|
|
ticket_id: ticket.id,
|
|
|
|
type_id: Ticket::Article::Type.where(name: 'phone' ).first.id,
|
|
|
|
sender_id: Ticket::Article::Sender.where(name: 'Customer' ).first.id,
|
|
|
|
from: 'Zammad Feedback <feedback@example.org>',
|
|
|
|
body: 'some <b>text</b><br>next line',
|
|
|
|
content_type: 'text/html',
|
|
|
|
internal: false,
|
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
2014-12-28 13:02:23 +00:00
|
|
|
)
|
|
|
|
tests = [
|
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
string: 'Subject #{ticket.title}',
|
|
|
|
result: 'Subject some title <b>äöüß</b> 2',
|
2014-12-28 13:02:23 +00:00
|
|
|
},
|
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
string: 'Subject #{article.from}, Group: #{ticket.group.name}',
|
|
|
|
result: 'Subject Zammad Feedback <feedback@example.org>, Group: Users',
|
2014-12-28 13:02:23 +00:00
|
|
|
},
|
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
string: 'Body #{article.body}, Group: #{ticket.group.name}',
|
|
|
|
result: 'Body some text
|
2015-01-06 14:30:00 +00:00
|
|
|
next line, Group: Users',
|
2014-12-28 13:02:23 +00:00
|
|
|
},
|
|
|
|
]
|
|
|
|
tests.each { |test|
|
|
|
|
result = NotificationFactory.build(
|
2015-04-27 13:42:53 +00:00
|
|
|
string: test[:string],
|
|
|
|
objects: {
|
|
|
|
ticket: ticket,
|
|
|
|
article: article_html,
|
|
|
|
recipient: User.find(2),
|
2014-12-28 13:02:23 +00:00
|
|
|
},
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: test[:locale]
|
2014-12-28 13:02:23 +00:00
|
|
|
)
|
2015-04-27 12:51:43 +00:00
|
|
|
assert_equal( test[:result], result, 'verify result' )
|
2014-12-28 13:02:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ticket.destroy
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'notifications attack' do
|
|
|
|
ticket = Ticket.create(
|
2015-04-27 13:42:53 +00:00
|
|
|
title: 'some title <b>äöüß</b> 3',
|
|
|
|
group: Group.lookup( name: 'Users'),
|
|
|
|
customer_id: 2,
|
|
|
|
state: Ticket::State.lookup( name: 'new' ),
|
|
|
|
priority: Ticket::Priority.lookup( name: '2 normal' ),
|
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
2014-12-28 13:02:23 +00:00
|
|
|
)
|
|
|
|
article_html = Ticket::Article.create(
|
2015-04-27 13:42:53 +00:00
|
|
|
ticket_id: ticket.id,
|
|
|
|
type_id: Ticket::Article::Type.where(name: 'phone' ).first.id,
|
|
|
|
sender_id: Ticket::Article::Sender.where(name: 'Customer' ).first.id,
|
|
|
|
from: 'Zammad Feedback <feedback@example.org>',
|
|
|
|
body: 'some <b>text</b><br>next line',
|
|
|
|
content_type: 'text/html',
|
|
|
|
internal: false,
|
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
2014-12-28 13:02:23 +00:00
|
|
|
)
|
|
|
|
tests = [
|
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
string: '\#{puts `ls`}',
|
|
|
|
result: '\#{puts `ls`} (not allowed)',
|
2014-12-28 13:02:23 +00:00
|
|
|
},
|
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
string: 'attack#1 #{article.destroy}',
|
|
|
|
result: 'attack#1 #{article.destroy} (not allowed)',
|
2014-12-28 13:02:23 +00:00
|
|
|
},
|
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
string: 'attack#2 #{Article.where}',
|
|
|
|
result: 'attack#2 #{Article.where} (not allowed)',
|
2014-12-28 13:02:23 +00:00
|
|
|
},
|
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
string: 'attack#1 #{article.
|
2014-12-28 13:02:23 +00:00
|
|
|
destroy}',
|
2015-04-27 13:42:53 +00:00
|
|
|
result: 'attack#1 #{article.
|
2015-01-02 22:34:37 +00:00
|
|
|
destroy} (not allowed)',
|
2014-12-28 13:02:23 +00:00
|
|
|
},
|
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
string: 'attack#1 #{article.find}',
|
|
|
|
result: 'attack#1 #{article.find} (not allowed)',
|
2014-12-28 13:02:23 +00:00
|
|
|
},
|
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
string: 'attack#1 #{article.update(:name => "test")}',
|
|
|
|
result: 'attack#1 #{article.update(:name => "test")} (not allowed)',
|
2014-12-28 13:02:23 +00:00
|
|
|
},
|
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
string: 'attack#1 #{article.all}',
|
|
|
|
result: 'attack#1 #{article.all} (not allowed)',
|
2014-12-28 13:02:23 +00:00
|
|
|
},
|
|
|
|
{
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
string: 'attack#1 #{article.delete}',
|
|
|
|
result: 'attack#1 #{article.delete} (not allowed)',
|
2014-12-28 13:02:23 +00:00
|
|
|
},
|
|
|
|
]
|
|
|
|
tests.each { |test|
|
|
|
|
result = NotificationFactory.build(
|
2015-04-27 13:42:53 +00:00
|
|
|
string: test[:string],
|
|
|
|
objects: {
|
|
|
|
ticket: ticket,
|
|
|
|
article: article_html,
|
|
|
|
recipient: User.find(2),
|
2013-01-04 14:28:55 +00:00
|
|
|
},
|
2015-04-27 13:42:53 +00:00
|
|
|
locale: test[:locale]
|
2013-01-04 14:28:55 +00:00
|
|
|
)
|
2015-04-27 12:51:43 +00:00
|
|
|
assert_equal( test[:result], result, 'verify result' )
|
2013-01-04 14:28:55 +00:00
|
|
|
}
|
2014-05-27 13:22:21 +00:00
|
|
|
|
|
|
|
ticket.destroy
|
2013-01-04 14:28:55 +00:00
|
|
|
end
|
2016-02-19 21:05:36 +00:00
|
|
|
|
|
|
|
test 'notifications template' do
|
|
|
|
groups = Group.where(name: 'Users')
|
|
|
|
roles = Role.where(name: 'Agent')
|
|
|
|
agent1 = User.create_or_update(
|
|
|
|
login: 'notification-template-agent1@example.com',
|
|
|
|
firstname: 'Notification<b>xxx</b>',
|
|
|
|
lastname: 'Agent1<b>yyy</b>',
|
|
|
|
email: 'notification-template-agent1@example.com',
|
|
|
|
password: 'agentpw',
|
|
|
|
active: true,
|
|
|
|
roles: roles,
|
|
|
|
groups: groups,
|
|
|
|
preferences: {
|
|
|
|
locale: 'de-de',
|
|
|
|
},
|
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
|
|
|
|
result = NotificationFactory.template(
|
|
|
|
template: 'password_reset',
|
|
|
|
locale: 'de-de',
|
|
|
|
objects: {
|
|
|
|
user: agent1,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
assert_match('Zurücksetzen Deines', result[:subject])
|
|
|
|
assert_match('wir haben eine Anfrage zum Zurücksetzen', result[:body])
|
|
|
|
assert_match('Dein', result[:body])
|
|
|
|
assert_match('Dein', result[:body])
|
|
|
|
assert_match('Notification<b>xxx</b>', result[:body])
|
|
|
|
assert_no_match('Your', result[:body])
|
|
|
|
|
|
|
|
result = NotificationFactory.template(
|
|
|
|
template: 'password_reset',
|
|
|
|
locale: 'de',
|
|
|
|
objects: {
|
|
|
|
user: agent1,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
assert_match('Zurücksetzen Deines', result[:subject])
|
|
|
|
assert_match('wir haben eine Anfrage zum Zurücksetzen', result[:body])
|
|
|
|
assert_match('Dein', result[:body])
|
|
|
|
assert_match('Notification<b>xxx</b>', result[:body])
|
|
|
|
assert_no_match('Your', result[:body])
|
|
|
|
|
|
|
|
result = NotificationFactory.template(
|
|
|
|
template: 'password_reset',
|
|
|
|
locale: 'es-us',
|
|
|
|
objects: {
|
|
|
|
user: agent1,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
assert_match('Reset your', result[:subject])
|
|
|
|
assert_match('We received a request to reset the password', result[:body])
|
|
|
|
assert_match('Your', result[:body])
|
|
|
|
assert_match('Notification<b>xxx</b>', result[:body])
|
|
|
|
assert_no_match('Dein', result[:body])
|
|
|
|
|
2016-02-20 07:43:44 +00:00
|
|
|
ticket = Ticket.create(
|
|
|
|
group_id: Group.where( name: 'Users' ).first.id,
|
|
|
|
customer_id: User.where( login: 'nicole.braun@zammad.org' ).first.id,
|
|
|
|
owner_id: User.where( login: '-' ).first.id,
|
|
|
|
title: 'Welcome to Zammad!',
|
|
|
|
state_id: Ticket::State.where( name: 'new' ).first.id,
|
|
|
|
priority_id: Ticket::Priority.where( name: '2 normal' ).first.id,
|
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
article = Ticket::Article.create(
|
|
|
|
ticket_id: ticket.id,
|
|
|
|
type_id: Ticket::Article::Type.where(name: 'phone' ).first.id,
|
|
|
|
sender_id: Ticket::Article::Sender.where(name: 'Customer' ).first.id,
|
|
|
|
from: 'Zammad Feedback <feedback@zammad.org>',
|
|
|
|
content_type: 'text/plain',
|
|
|
|
body: 'Welcome!
|
|
|
|
<b>test123</b>',
|
|
|
|
internal: false,
|
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
|
2016-02-19 21:05:36 +00:00
|
|
|
changes = {}
|
|
|
|
result = NotificationFactory.template(
|
|
|
|
template: 'ticket_create',
|
|
|
|
locale: 'es-us',
|
|
|
|
objects: {
|
|
|
|
ticket: ticket,
|
|
|
|
article: article,
|
|
|
|
recipient: agent1,
|
|
|
|
changes: changes,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
assert_match('New Ticket', result[:subject])
|
|
|
|
assert_match('Notification<b>xxx</b>', result[:body])
|
|
|
|
assert_match('has been created by', result[:body])
|
2016-02-20 07:43:44 +00:00
|
|
|
assert_match('<b>test123</b>', result[:body])
|
2016-02-19 21:05:36 +00:00
|
|
|
assert_match('Manage your notifications settings', result[:body])
|
|
|
|
assert_no_match('Dein', result[:body])
|
|
|
|
|
|
|
|
result = NotificationFactory.template(
|
|
|
|
template: 'ticket_create',
|
|
|
|
locale: 'de-de',
|
|
|
|
objects: {
|
|
|
|
ticket: ticket,
|
|
|
|
article: article,
|
|
|
|
recipient: agent1,
|
|
|
|
changes: changes,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
assert_match('Neues Ticket', result[:subject])
|
|
|
|
assert_match('Notification<b>xxx</b>', result[:body])
|
|
|
|
assert_match('es wurde ein neues Ticket', result[:body])
|
2016-02-20 07:43:44 +00:00
|
|
|
assert_match('<b>test123</b>', result[:body])
|
2016-02-19 21:05:36 +00:00
|
|
|
assert_match('Manage your notifications settings', result[:body])
|
|
|
|
assert_no_match('Your', result[:body])
|
|
|
|
|
2016-02-20 07:43:44 +00:00
|
|
|
article = Ticket::Article.create(
|
|
|
|
ticket_id: ticket.id,
|
|
|
|
type_id: Ticket::Article::Type.where(name: 'phone' ).first.id,
|
|
|
|
sender_id: Ticket::Article::Sender.where(name: 'Customer' ).first.id,
|
|
|
|
from: 'Zammad Feedback <feedback@zammad.org>',
|
|
|
|
content_type: 'text/html',
|
|
|
|
body: 'Welcome!
|
|
|
|
<b>test123</b>',
|
|
|
|
internal: false,
|
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
2016-02-19 21:05:36 +00:00
|
|
|
changes = {
|
|
|
|
state: %w(aaa bbb),
|
|
|
|
group: %w(xxx yyy),
|
|
|
|
}
|
|
|
|
result = NotificationFactory.template(
|
|
|
|
template: 'ticket_update',
|
|
|
|
locale: 'es-us',
|
|
|
|
objects: {
|
|
|
|
ticket: ticket,
|
|
|
|
article: article,
|
|
|
|
recipient: agent1,
|
|
|
|
changes: changes,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
assert_match('Updated Ticket', result[:subject])
|
|
|
|
assert_match('Notification<b>xxx</b>', result[:body])
|
|
|
|
assert_match('has been updated by', result[:body])
|
2016-02-20 07:43:44 +00:00
|
|
|
assert_match('<b>test123</b>', result[:body])
|
2016-02-19 21:05:36 +00:00
|
|
|
assert_match('Manage your notifications settings', result[:body])
|
|
|
|
assert_no_match('Dein', result[:body])
|
|
|
|
|
|
|
|
result = NotificationFactory.template(
|
|
|
|
template: 'ticket_update',
|
|
|
|
locale: 'de-de',
|
|
|
|
objects: {
|
|
|
|
ticket: ticket,
|
|
|
|
article: article,
|
|
|
|
recipient: agent1,
|
|
|
|
changes: changes,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
assert_match('Ticket aktualisiert', result[:subject])
|
|
|
|
assert_match('Notification<b>xxx</b>', result[:body])
|
|
|
|
assert_match('wurde von', result[:body])
|
2016-02-20 07:43:44 +00:00
|
|
|
assert_match('<b>test123</b>', result[:body])
|
2016-02-19 21:05:36 +00:00
|
|
|
assert_match('Manage your notifications settings', result[:body])
|
|
|
|
assert_no_match('Your', result[:body])
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2015-04-27 14:15:29 +00:00
|
|
|
end
|