From ce937627d8e950a89558f30064822bd1c2a90665 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 23 Oct 2015 13:02:11 +0200 Subject: [PATCH] Added new test case. --- app/models/user.rb | 1 + test/fixtures/mail35.box | 63 +++++++++++++++++++++++++++++++++ test/unit/email_process_test.rb | 24 +++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 test/fixtures/mail35.box diff --git a/app/models/user.rb b/app/models/user.rb index 3c76b8c40..83a4be3c6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -536,6 +536,7 @@ returns return if !email return if email.empty? + return if email !~ /@/ # save/update avatar avatar = Avatar.auto_detection( diff --git a/test/fixtures/mail35.box b/test/fixtures/mail35.box new file mode 100644 index 000000000..c2ebe04e4 --- /dev/null +++ b/test/fixtures/mail35.box @@ -0,0 +1,63 @@ +From MAILER-DAEMON Wed Oct 21 14:42:20 2015 +Return-Path: <> +X-Original-To: info@example.com +Delivered-To: znuny-sales@arber.example.com +Received-SPF: pass (emea01-am1-obe.outbound.protection.example.com: Sender is authorized to use 'emea01-am1-obe.outbound.protection.example.com' in 'helo' identity (mechanism 'include:spf.protection.example.com' matched)) receiver=arber.example.com; identity=helo; helo=emea01-am1-obe.outbound.protection.example.com; client-ip=7.5.1.1 +Received: from emea01-am1-obe.outbound.protection.example.com (mail-am1hn0251.outbound.protection.example.com [7.5.1.1]) + by arber.example.com (Postfix) with ESMTPS id C45775FE6A + for ; Wed, 21 Oct 2015 14:42:20 +0200 (CEST) +Received: from DB5PR07MB1224.eurprd07.example.com (10.164.41.30) by + DB5PR07MB1271.eurprd07.example.com (10.164.41.149) with Microsoft SMTP + Server (TLS) id 15.1.306.13; Wed, 21 Oct 2015 12:42:19 +0000 +Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=<>; +Received: from [10.254.48.3] (7.1.5.1) by + DB5PR07MB1224.eurprd07.example.com (10.164.41.30) with Microsoft SMTP + Server (TLS) id 15.1.306.13; Wed, 21 Oct 2015 12:42:17 +0000 +Content-Type: text/plain; charset="iso-8859-1" +MIME-Version: 1.0 +Content-Transfer-Encoding: quoted-printable +Content-Description: Mail message body +Subject: Darlehen bieten jetzt bewerben +To: Recipients +From: "finances8@firstfinanceloanfirm.example.com" +Date: Wed, 21 Oct 2015 13:42:12 +0100 +Reply-To: +X-Originating-IP: [7.1.5.1] +X-ClientProxiedBy: HE1PR08CA0021.eurprd08.example.com (2.1.1.3) To + DB5PR07MB1224.eurprd07.example.com (2.1.1.3) +Message-ID: +X-Microsoft-Exchange-Diagnostics: 1;DB5PR07MB1224;2:DvCxn5dPPr2amttb4PujSx7+t6AMFJ+bMPumYN+Dk+H69oto3H01nPU6iR11JyZqjYuc39aPa1k5lilg1WbAYYC0kHdc2mKQP3cz6inS9RukNIIjp80dpFcfU8yflVZsNY8ZgQpWUUY7t8/8kVwNIk4irQFGZXQoXvabUNTR0WE=;3:cJIJTbFfruxjzzq+oDnnGOByaWjKlJGDX3cpo5L+mAR1hw2L5a0fZMkF3wYG+q+GZ8gm2Ylq6Mqhfe6fE0w4uQLvzgqAmKpB3fRRKpApA2W/raC1ervusTDeQp52bwLkuFDfafHeNQyk2ZKMsnFPdQ==;25:ZG++cyGnY1E1dIVYBdN/Zy/fWvaRwl1E1dSpIYrR18AaPp28qkBntNH1fJG8RZLm/ZyOXWGw9Yj6u9ycoyUSCUKmNWSPdSSUfbAoKlwBnZLbzpwmYToJzorzroT+EVXsCkCrGkfMfok+gjpl9H+9az4RQrW8rhwMhSIdA/Ilc3Kd+rNgBJ4sOSqGS7nTbtZHBbW81iXT++s4ab0Jh5KvMc43ue6tDVfHYc3rd1Trr7bBGV+iyE0wtgg164SEMp+3mOaFVMI6UmnL+IDj+bOZGA== +X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB5PR07MB1224; +X-Microsoft-Antispam-PRVS: +X-Exchange-Antispam-Report-Test: UriScan:; +X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(520078)(8121501046)(3002001)(102115026)(6004014)(6003046);SRVR:DB5PR07MB1224;BCL:0;PCL:0;RULEID:;SRVR:DB5PR07MB1224; +X-Microsoft-Exchange-Diagnostics: 1;DB5PR07MB1224;4:nnPVuJcrP/HGkCckgwKl7aJvC3EaZ0krj8ntX+WiSR1I+giYX9zPNwiki/7fIAWLYxxG0/aIQ//rReEVZrd/V2EH+PiNIDAHyVGNKBrGHB2R8P4vyh1fHBs8j1bEKNxn+t+4cFXEs7HYuSej9JY/BnQ34PnAsyViJtlWyibsUufjDNziP9JprRSgQf5zcSyffl73Ut0tY6pbX0v9ACVplnon07EhYYRfiBeu2cl6omrPINzMKDUt0BHunryPvXPOMl59CjTavddWiX0aJp/6ZwjF9R7nmgg9hS265qdEUOVhUPEe7cXjC8J3MLvq0auhgaJJVzNtmif56p4CW4eq2XMFbLthte3ORVmY9D8dhcR7tnHh/k9DLTx4zxUrFQWQPx86GNoo4mNssG4uGzUnHtetiDh9OtJbEL6s0aDZQVg=;23:0DFgc9QSh0ZIGritIv/KheEacJ7MAOinGXlKMABgvrIv9kljhHyju2F3owCE3OSUEedBv1vFu2s8OZnJ4m39lvMSxNIrow2MI29QxsoczYojmWHTECeAvkzJ4BYOhR4V0+iv1k1j4jDPFc9eVVY1Wel/ZJuS5DUIdNND9DnUwA2Zyzjm7ng7LF0znPz49lTbW/dkVCg6w4poryjMKWF3+xxT8Wefz7IonyAj+rI666JjaHVgk4puOoRAnDMHdvBF;5:P3QUjzpnvXNdNhdd5ZBd2CjBrl8LjhhxuAV/rMzKVdJCZh8FW6/ILeucXd8JU98DA8RrICLmdb1hbv2KBz4KexXoUD/VQYTn2qAjNqeIChjcjflvgsf6PwlPh4bs9HD+VK8NUSzGd21NkCznQFJaAQ==;24:JiXy13k+O7JUOG7IkzPwFd4RbRutN4QyGqlwL0SWbYsF86ynPrmE0/MLL0JCRqEzzED4KqdqJ2pQ1w86dG0EcA== +X-Forefront-PRVS: 073631BD3D +X-Forefront-Antispam-Report: SFV:SPM;SFS:(10019020)(6009001)(6049001)(5005620100007);DIR:OUT;SFP:1501;SCL:9;SRVR:DB5PR07MB1224;H:[10.254.48.3];FPR:;SPF:None;PTR:InfoNoRecords;LANG:de; +Received-SPF: None (protection.example.com: [10.254.48.3] does not designate + permitted sender hosts) +SpamDiagnosticOutput: 1:22 +SpamDiagnosticMetadata: 00000000%2D0000%2D0000%2D0000%2D000000000000 +X-Microsoft-Exchange-Diagnostics: 1;DB5PR07MB1224;20:zTAZboReXzFThEimKWUfvgFhjfgaw9a0rToyXCe6+Kb8dHZcQ9EjKmYZWkE62uOnvD4VLpAKakk1FJwRcDxBBA== +X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2015 12:42:17.1900 + (UTC) +X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted +X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR07MB1224 +X-Microsoft-Exchange-Diagnostics: 1;DB5PR07MB1271;2:5HuMfuoIxYZexWzVgqBch/cN+KXYALcB840unggr+hi7mPMTcPb63gD0Z0sgz1HuRne2t9tCnGlWIfcn7XCzXAAHvuIYuHjTHbFaj/WV0iy94Ehgo6XuM5GfqRlGTuUa/LyJi/BcfZ0jchcBrVjVt0Izn4+UB09P6yRq1/A0YjA=;23:mJyNLyB8E9W7POa18G8yfp1BVI8DgT6RzrItoW2V7KLBKMxiHx443g93/0YeXjBYWpeaIaMy5B9GA5i17vOeCKJZs+LimKbls83Ia+npZB7SXdJj6mBaWAdGwmW9lJ8ePnh1YjSS2oNXepT+uy7E6FZPxqWh3HDN8GJ8u/LJzupxeISrRds+T9crHSexnyVz +X-OriginatorOrg: firstfinanceloanfirm.example.com +X-UID: 3783 +Status: RO +Content-Length: 397 +Lines: 10 + +Beantworten :firstfinancelender@example.com + +Ich Mr.Squires Peter ist eine zuverl=E4ssige Kreditangebot mit einer +Rate von 1.5% f=FCr den Zeitraum von 1 bis 40yrs nur, von der minimalen +von 5,000.00euro sie an die maximale Menge an 150,000.000.00euro, so +dass f=FCr mehr Details, wenn interessiert kontaktieren Sie mich unter + +firstfinancelender@example.com + +Beantworten :firstfinancelender@example.com + diff --git a/test/unit/email_process_test.rb b/test/unit/email_process_test.rb index ab2996246..77460ee25 100644 --- a/test/unit/email_process_test.rb +++ b/test/unit/email_process_test.rb @@ -1953,6 +1953,30 @@ Some Text', ], } }, + { + data: IO.read('test/fixtures/mail35.box'), + success: true, + result: { + 0 => { + priority: '2 normal', + title: 'Darlehen bieten jetzt bewerben', + }, + 1 => { + sender: 'Customer', + type: 'email', + }, + }, + verify: { + users: [ + { + firstname: '', + lastname: '', + fullname: '"finances8@firstfinanceloanfirm.example.com"', + email: '"finances8@firstfinanceloanfirm.example.com"', + }, + ], + } + }, ] process(files) end