diff options
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 7 | ||||
-rw-r--r-- | railties/lib/rails_generator/generators/components/mailer/templates/unit_test.rb | 8 |
2 files changed, 10 insertions, 5 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 8b04c42ee0..67141c461b 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -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| diff --git a/railties/lib/rails_generator/generators/components/mailer/templates/unit_test.rb b/railties/lib/rails_generator/generators/components/mailer/templates/unit_test.rb index 70fd3afe37..0874a6fd91 100644 --- a/railties/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +++ b/railties/lib/rails_generator/generators/components/mailer/templates/unit_test.rb @@ -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 |