Fix for non-english email polling.

This commit is contained in:
Robin Ward 2013-11-04 15:30:24 -05:00
parent b8e63719f8
commit c86b06e3fa
3 changed files with 29 additions and 1 deletions

View file

@ -26,7 +26,7 @@ module Email
return Email::Receiver.results[:unprocessable] if @body.blank?
# Then run the github EmailReplyParser on it in case we didn't catch it
@body = EmailReplyParser.read(@body).visible_text
@body = EmailReplyParser.read(@body).visible_text.force_encoding('UTF-8')
discourse_email_parser

View file

@ -50,6 +50,17 @@ stripped from my reply?")
end
end
describe "It supports a non english reply" do
let(:hebrew) { File.read("#{Rails.root}/spec/fixtures/emails/hebrew.eml") }
let(:receiver) { Email::Receiver.new(hebrew) }
it "processes correctly" do
I18n.expects(:t).with('user_notifications.previous_discussion').returns('כלטוב')
receiver.process
expect(receiver.body).to eq("שלום")
end
end
describe "via" do
let(:wrote) { File.read("#{Rails.root}/spec/fixtures/emails/via_line.eml") }
let(:receiver) { Email::Receiver.new(wrote) }

17
spec/fixtures/emails/hebrew.eml vendored Normal file
View file

@ -0,0 +1,17 @@
Delivered-To: discourse-reply+cd480e301683c9902891f15968bf07a5@discourse.org
Received: by 10.194.216.104 with SMTP id op8csp80593wjc;
Wed, 24 Jul 2013 07:59:14 -0700 (PDT)
Return-Path: <walter.white@googlemail.com>
References: <topic/5043@discourse.org> <51efeb9b36c34_66dc2dfce6811866@discourse.mail>
From: Walter White <walter.white@googlemail.com>
In-Reply-To: <51efeb9b36c34_66dc2dfce6811866@discourse.mail>
Mime-Version: 1.0 (1.0)
Date: Wed, 24 Jul 2013 15:59:10 +0100
Message-ID: <4597127794206131679@unknownmsgid>
Subject: Re: [Discourse] new reply to your post in 'Crystal Blue'
To: walter via Discourse <discourse-reply+cd480e301683c9902891f15968bf07a5@discourse.org>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: base64
16nXnNeV150=