From 345e622a20fd14a356a69da40e527075b1117b52 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Wed, 30 Dec 2009 16:12:51 +1100 Subject: [PATCH] Adding TMailCompat layer for :set_content_type and friends --- actionmailer/lib/action_mailer.rb | 2 ++ actionmailer/lib/action_mailer/tmail_compat.rb | 10 ++++++++++ actionmailer/test/tmail_compat_test.rb | 14 ++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 actionmailer/lib/action_mailer/tmail_compat.rb create mode 100644 actionmailer/test/tmail_compat_test.rb diff --git a/actionmailer/lib/action_mailer.rb b/actionmailer/lib/action_mailer.rb index 55ddbb24f4..039715c2f5 100644 --- a/actionmailer/lib/action_mailer.rb +++ b/actionmailer/lib/action_mailer.rb @@ -45,3 +45,5 @@ module Text autoload :Format, 'action_mailer/vendor/text_format' end + +require 'action_mailer/tmail_compat' \ No newline at end of file diff --git a/actionmailer/lib/action_mailer/tmail_compat.rb b/actionmailer/lib/action_mailer/tmail_compat.rb new file mode 100644 index 0000000000..cacd79be27 --- /dev/null +++ b/actionmailer/lib/action_mailer/tmail_compat.rb @@ -0,0 +1,10 @@ +module Mail + class Message + + def set_content_type(*args) + STDERR.puts("Message#set_content_type is deprecated, please just call Message#content_type with the same arguments.\n#{caller}") + content_type(*args) + end + + end +end \ No newline at end of file diff --git a/actionmailer/test/tmail_compat_test.rb b/actionmailer/test/tmail_compat_test.rb new file mode 100644 index 0000000000..9b0e91f5f8 --- /dev/null +++ b/actionmailer/test/tmail_compat_test.rb @@ -0,0 +1,14 @@ +require 'abstract_unit' + +class TmailCompatTest < Test::Unit::TestCase + + def test_set_content_type_raises_deprecation_warning + mail = Mail.new + STDERR.expects(:puts) # Deprecation warning + assert_nothing_raised do + mail.set_content_type "text/plain" + end + assert_equal mail.content_type.string, "text/plain" + end + +end