mirror of https://github.com/rails/rails
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
|
@ -140,13 +140,12 @@ module ActionMailer #:nodoc:
|
||||||
send("perform_delivery_#{delivery_method}", mail) if perform_deliveries
|
send("perform_delivery_#{delivery_method}", mail) if perform_deliveries
|
||||||
end
|
end
|
||||||
|
|
||||||
def quoted_printable( text, charset )
|
def quoted_printable(text, charset)
|
||||||
text = text.gsub( /[^a-z ]/i ) { "=%02x" % $&[0] }.
|
text = text.gsub( /[^a-z ]/i ) { "=%02x" % $&[0] }.gsub( / /, "_" )
|
||||||
gsub( / /, "_" )
|
|
||||||
"=?#{charset}?Q?#{text}?="
|
"=?#{charset}?Q?#{text}?="
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def perform_delivery_smtp(mail)
|
def perform_delivery_smtp(mail)
|
||||||
Net::SMTP.start(server_settings[:address], server_settings[:port], server_settings[:domain],
|
Net::SMTP.start(server_settings[:address], server_settings[:port], server_settings[:domain],
|
||||||
server_settings[:user_name], server_settings[:password], server_settings[:authentication]) do |smtp|
|
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
|
class <%= class_name %>Test < Test::Unit::TestCase
|
||||||
FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures'
|
FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures'
|
||||||
|
CHARSET = "utf-8"
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
ActionMailer::Base.delivery_method = :test
|
ActionMailer::Base.delivery_method = :test
|
||||||
|
@ -10,11 +11,12 @@ class <%= class_name %>Test < Test::Unit::TestCase
|
||||||
ActionMailer::Base.deliveries = []
|
ActionMailer::Base.deliveries = []
|
||||||
|
|
||||||
@expected = TMail::Mail.new
|
@expected = TMail::Mail.new
|
||||||
|
@expected.set_content_type "text", "plain", { "charset" => CHARSET }
|
||||||
end
|
end
|
||||||
|
|
||||||
<% for action in actions -%>
|
<% for action in actions -%>
|
||||||
def test_<%= action %>
|
def test_<%= action %>
|
||||||
@expected.subject = '<%= class_name %>#<%= action %>'
|
@expected.subject = encode '<%= class_name %>#<%= action %>'
|
||||||
@expected.body = read_fixture('<%= action %>')
|
@expected.body = read_fixture('<%= action %>')
|
||||||
@expected.date = Time.now
|
@expected.date = Time.now
|
||||||
|
|
||||||
|
@ -26,4 +28,8 @@ class <%= class_name %>Test < Test::Unit::TestCase
|
||||||
def read_fixture(action)
|
def read_fixture(action)
|
||||||
IO.readlines("#{FIXTURES_PATH}/<%= file_name %>/#{action}")
|
IO.readlines("#{FIXTURES_PATH}/<%= file_name %>/#{action}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def encode(subject)
|
||||||
|
ActionMailer::Base.quoted_printable(subject, CHARSET)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue