From bcc72a97938b6395a9df069f9ee806f35358425f Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 1 Sep 2015 01:07:07 +0200 Subject: [PATCH] Improved observer for better testing. --- app/models/observer/ticket/article/fillup_from_email.rb | 8 +++++--- test/unit/email_process_test.rb | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/models/observer/ticket/article/fillup_from_email.rb b/app/models/observer/ticket/article/fillup_from_email.rb index d0735373b..beb9f3a05 100644 --- a/app/models/observer/ticket/article/fillup_from_email.rb +++ b/app/models/observer/ticket/article/fillup_from_email.rb @@ -26,9 +26,11 @@ class Observer::Ticket::Article::FillupFromEmail < ActiveRecord::Observer # clean subject record.subject = ticket.subject_clean( record.subject ) - # generate message id - fqdn = Setting.get('fqdn') - record.message_id = '<' + DateTime.current.to_s(:number) + '.' + record.ticket_id.to_s + '.' + rand(999_999).to_s() + '@' + fqdn + '>' + # generate message id, force it in prodution, in test allow to set it for testing reasons + if !record.message_id || Rails.env.production? + fqdn = Setting.get('fqdn') + record.message_id = '<' + DateTime.current.to_s(:number) + '.' + record.ticket_id.to_s + '.' + rand(999_999).to_s() + '@' + fqdn + '>' + end # generate message_id_md5 record.check_message_id_md5 diff --git a/test/unit/email_process_test.rb b/test/unit/email_process_test.rb index 706ca3d25..acbaa198a 100644 --- a/test/unit/email_process_test.rb +++ b/test/unit/email_process_test.rb @@ -2038,9 +2038,9 @@ Some Text', ticket_id: ticket.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', - subject: 'some subject', + subject: 'bounce check', message_id: '<20150830145601.30.608881@edenhofer.zammad.com>', - body: 'some message article', + body: 'some message bounce check', internal: false, sender: Ticket::Article::Sender.where(name: 'Agent').first, type: Ticket::Article::Type.where(name: 'email').first,