From e1059d4ece7e3376f3c7a783aa072fa746662990 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 13 Feb 2017 15:05:28 +0100 Subject: [PATCH] Followup for issue#719 - ensure that title is set even via email creation. --- app/models/channel/email_parser.rb | 6 +++- test/unit/email_process_test.rb | 49 ++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/app/models/channel/email_parser.rb b/app/models/channel/email_parser.rb index fe215fc52..8d1d6e5f3 100644 --- a/app/models/channel/email_parser.rb +++ b/app/models/channel/email_parser.rb @@ -512,9 +512,13 @@ returns if !group group = Group.first end + title = mail[:subject] + if title.blank? + title = '-' + end ticket = Ticket.new( group_id: group.id, - title: mail[:subject] || '', + title: title, preferences: preferences, ) set_attributes_by_x_headers(ticket, 'ticket', mail) diff --git a/test/unit/email_process_test.rb b/test/unit/email_process_test.rb index 2b7c71655..4004a703c 100644 --- a/test/unit/email_process_test.rb +++ b/test/unit/email_process_test.rb @@ -72,6 +72,51 @@ Some Textäöü", { data: "From: me@example.com To: customer@example.com +Subject: + +Some Textäöü without subject#1", + channel: { + trusted: false, + }, + success: true, + result: { + 0 => { + priority: '2 normal', + title: '-', + }, + 1 => { + body: 'Some Textäöü without subject#1', + sender: 'Customer', + type: 'email', + internal: false, + }, + }, + }, + { + data: "From: me@example.com +To: customer@example.com + +Some Textäöü without subject#2", + channel: { + trusted: false, + }, + success: true, + result: { + 0 => { + priority: '2 normal', + title: '-', + }, + 1 => { + body: 'Some Textäöü without subject#2', + sender: 'Customer', + type: 'email', + internal: false, + }, + }, + }, + { + data: "From: me@example.com +To: customer@example.com Subject: äöü some subject Some Textäöü".encode('ISO-8859-1'), @@ -79,7 +124,7 @@ Some Textäöü".encode('ISO-8859-1'), result: { 0 => { priority: '2 normal', - title: '', # should be äöü some subject, but can not be parsed from mime tools + title: '-', # should be äöü some subject, but can not be parsed from mime tools }, 1 => { body: 'Some Textäöü', @@ -206,7 +251,7 @@ Some Text", result: { 0 => { priority: '2 normal', - title: '', + title: '-', }, 1 => { from: 'marketingmanager@nthcpghana.com',