mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Made Action Mailer templates use UTF-8 as default
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@739 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
cf659de141
commit
148f6d8fb6
2 changed files with 10 additions and 5 deletions
|
@ -140,13 +140,12 @@ module ActionMailer #:nodoc:
|
|||
send("perform_delivery_#{delivery_method}", mail) if perform_deliveries
|
||||
end
|
||||
|
||||
def quoted_printable( text, charset )
|
||||
text = text.gsub( /[^a-z ]/i ) { "=%02x" % $&[0] }.
|
||||
gsub( / /, "_" )
|
||||
def quoted_printable(text, charset)
|
||||
text = text.gsub( /[^a-z ]/i ) { "=%02x" % $&[0] }.gsub( / /, "_" )
|
||||
"=?#{charset}?Q?#{text}?="
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
def perform_delivery_smtp(mail)
|
||||
Net::SMTP.start(server_settings[:address], server_settings[:port], server_settings[:domain],
|
||||
server_settings[:user_name], server_settings[:password], server_settings[:authentication]) do |smtp|
|
||||
|
|
|
@ -3,6 +3,7 @@ require '<%= file_name %>'
|
|||
|
||||
class <%= class_name %>Test < Test::Unit::TestCase
|
||||
FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures'
|
||||
CHARSET = "utf-8"
|
||||
|
||||
def setup
|
||||
ActionMailer::Base.delivery_method = :test
|
||||
|
@ -10,11 +11,12 @@ class <%= class_name %>Test < Test::Unit::TestCase
|
|||
ActionMailer::Base.deliveries = []
|
||||
|
||||
@expected = TMail::Mail.new
|
||||
@expected.set_content_type "text", "plain", { "charset" => CHARSET }
|
||||
end
|
||||
|
||||
<% for action in actions -%>
|
||||
def test_<%= action %>
|
||||
@expected.subject = '<%= class_name %>#<%= action %>'
|
||||
@expected.subject = encode '<%= class_name %>#<%= action %>'
|
||||
@expected.body = read_fixture('<%= action %>')
|
||||
@expected.date = Time.now
|
||||
|
||||
|
@ -26,4 +28,8 @@ class <%= class_name %>Test < Test::Unit::TestCase
|
|||
def read_fixture(action)
|
||||
IO.readlines("#{FIXTURES_PATH}/<%= file_name %>/#{action}")
|
||||
end
|
||||
|
||||
def encode(subject)
|
||||
ActionMailer::Base.quoted_printable(subject, CHARSET)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue