From eb085beea8607b76c52aba00c41a8eaab13197ed Mon Sep 17 00:00:00 2001 From: Sam <sam.saffron@gmail.com> Date: Fri, 26 Apr 2013 13:57:33 +1000 Subject: [PATCH] attempt to fix the UTF-8 warn in the log, turns out this runs really deep, when you hit deliver in test it clones the mail not setting charset properly, leaving as is for today but fixing prod at least --- lib/email_builder.rb | 1 + lib/email_sender.rb | 3 ++- spec/components/system_message_spec.rb | 12 +----------- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/email_builder.rb b/lib/email_builder.rb index 2249865c4..dabd9ef2a 100644 --- a/lib/email_builder.rb +++ b/lib/email_builder.rb @@ -20,6 +20,7 @@ module EmailBuilder body: body } mail_args[:from] = params[:from] || SiteSetting.notification_email + mail_args[:charset] = 'UTF-8' mail(mail_args) end diff --git a/lib/email_sender.rb b/lib/email_sender.rb index 2265a13c7..495542b18 100644 --- a/lib/email_sender.rb +++ b/lib/email_sender.rb @@ -19,7 +19,8 @@ class EmailSender return if @message.to.blank? return if @message.body.blank? - plain_body = @message.body.to_s + @message.charset = 'UTF-8' + plain_body = @message.body.to_s.force_encoding('UTF-8') @message.html_part = Mail::Part.new do content_type 'text/html; charset=UTF-8' diff --git a/spec/components/system_message_spec.rb b/spec/components/system_message_spec.rb index 2a976f550..c32656816 100644 --- a/spec/components/system_message_spec.rb +++ b/spec/components/system_message_spec.rb @@ -13,22 +13,12 @@ describe SystemMessage do let(:post) { system_message.create(:welcome_invite) } let(:topic) { post.topic } - it 'should create a post' do + it 'should create a post correctly' do post.should be_present - end - - it 'should be a private message' do topic.should be_private_message - end - - it 'should have the correct topic subtype' do topic.subtype.should == TopicSubtype.system_message - end - - it 'should be visible by the user' do topic.allowed_users.include?(user).should be_true end - end context '#system_user' do