From 497b65950098d5f8cddb5a6aa4f918667a8454f5 Mon Sep 17 00:00:00 2001
From: Martin Edenhofer
Date: Sat, 20 Feb 2016 08:43:44 +0100
Subject: [PATCH] Fixed text/html article quoting in notifications.
---
app/views/mailer/application.html.erb | 2 +-
app/views/mailer/ticket_create/de.html.erb | 2 +-
app/views/mailer/ticket_create/en.html.erb | 2 +-
app/views/mailer/ticket_update/en.html.erb | 2 +-
lib/notification_factory.rb | 2 +-
test/unit/notification_factory_test.rb | 43 ++++++++++++++++++++--
6 files changed, 44 insertions(+), 9 deletions(-)
diff --git a/app/views/mailer/application.html.erb b/app/views/mailer/application.html.erb
index 3c5d5d262..61daf3ccb 100644
--- a/app/views/mailer/application.html.erb
+++ b/app/views/mailer/application.html.erb
@@ -38,5 +38,5 @@
<%= d 'message', false %>
\ No newline at end of file
diff --git a/app/views/mailer/ticket_create/de.html.erb b/app/views/mailer/ticket_create/de.html.erb
index 5d5c07a02..a257d2aac 100644
--- a/app/views/mailer/ticket_create/de.html.erb
+++ b/app/views/mailer/ticket_create/de.html.erb
@@ -14,7 +14,7 @@ Neues Ticket (<%= d 'ticket.title' %>)
<%= t 'Information' %>:
- <%= d('article.body').text2html %>
+ <%= a 'article' %>
<% end %>
diff --git a/app/views/mailer/ticket_create/en.html.erb b/app/views/mailer/ticket_create/en.html.erb
index 78dda990c..d1569f20c 100644
--- a/app/views/mailer/ticket_create/en.html.erb
+++ b/app/views/mailer/ticket_create/en.html.erb
@@ -14,7 +14,7 @@ New Ticket (<%= d 'ticket.title' %>)
<%= t 'Information' %>:
- <%= d('article.body').text2html %>
+ <%= a 'article' %>
<% end %>
diff --git a/app/views/mailer/ticket_update/en.html.erb b/app/views/mailer/ticket_update/en.html.erb
index e8ac7cd50..e62b58381 100644
--- a/app/views/mailer/ticket_update/en.html.erb
+++ b/app/views/mailer/ticket_update/en.html.erb
@@ -19,7 +19,7 @@ Ticket (<%= d 'ticket.title' %>) has been updated by "<%= d 'ticket.updated_b
<%= t 'Information' %>:
- <%= d('article.body').text2html %>
+ <%= a 'article' %>
<% end %>
diff --git a/lib/notification_factory.rb b/lib/notification_factory.rb
index 5293530f8..41141b8e5 100644
--- a/lib/notification_factory.rb
+++ b/lib/notification_factory.rb
@@ -297,7 +297,7 @@ module NotificationFactory
if content_type =~ /html/
return d "#{article}.body", false
end
- d("#{article}.content_type", false).text2html
+ d("#{article}.body", false).text2html
end
def h(key)
diff --git a/test/unit/notification_factory_test.rb b/test/unit/notification_factory_test.rb
index b6c03e5a3..277e083b1 100644
--- a/test/unit/notification_factory_test.rb
+++ b/test/unit/notification_factory_test.rb
@@ -356,8 +356,29 @@ next line, Group: Users',
assert_match('Notification<b>xxx</b>', result[:body])
assert_no_match('Dein', result[:body])
- ticket = Ticket.first
- article = ticket.articles.first
+ 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 ',
+ content_type: 'text/plain',
+ body: 'Welcome!
+test123',
+ internal: false,
+ updated_by_id: 1,
+ created_by_id: 1,
+ )
+
changes = {}
result = NotificationFactory.template(
template: 'ticket_create',
@@ -372,6 +393,7 @@ next line, Group: Users',
assert_match('New Ticket', result[:subject])
assert_match('Notification<b>xxx</b>', result[:body])
assert_match('has been created by', result[:body])
+ assert_match('<b>test123</b>', result[:body])
assert_match('Manage your notifications settings', result[:body])
assert_no_match('Dein', result[:body])
@@ -388,11 +410,22 @@ next line, Group: Users',
assert_match('Neues Ticket', result[:subject])
assert_match('Notification<b>xxx</b>', result[:body])
assert_match('es wurde ein neues Ticket', result[:body])
+ assert_match('<b>test123</b>', result[:body])
assert_match('Manage your notifications settings', result[:body])
assert_no_match('Your', result[:body])
- ticket = Ticket.first
- article = ticket.articles.first
+ 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 ',
+ content_type: 'text/html',
+ body: 'Welcome!
+test123',
+ internal: false,
+ updated_by_id: 1,
+ created_by_id: 1,
+ )
changes = {
state: %w(aaa bbb),
group: %w(xxx yyy),
@@ -410,6 +443,7 @@ next line, Group: Users',
assert_match('Updated Ticket', result[:subject])
assert_match('Notification<b>xxx</b>', result[:body])
assert_match('has been updated by', result[:body])
+ assert_match('test123', result[:body])
assert_match('Manage your notifications settings', result[:body])
assert_no_match('Dein', result[:body])
@@ -426,6 +460,7 @@ next line, Group: Users',
assert_match('Ticket aktualisiert', result[:subject])
assert_match('Notification<b>xxx</b>', result[:body])
assert_match('wurde von', result[:body])
+ assert_match('test123', result[:body])
assert_match('Manage your notifications settings', result[:body])
assert_no_match('Your', result[:body])