From a6eed86c33fbd074a08b76a678e968f521cf37b0 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Mon, 23 Nov 2009 20:50:49 +1100 Subject: Removing utils, and updating requires to match --- actionmailer/CHANGELOG | 14 +++++++------- actionmailer/lib/action_mailer.rb | 5 ++--- actionmailer/lib/action_mailer/base.rb | 6 +++--- actionmailer/lib/action_mailer/utils.rb | 7 ------- 4 files changed, 12 insertions(+), 20 deletions(-) delete mode 100644 actionmailer/lib/action_mailer/utils.rb (limited to 'actionmailer') diff --git a/actionmailer/CHANGELOG b/actionmailer/CHANGELOG index 0d16540661..9b07686b64 100644 --- a/actionmailer/CHANGELOG +++ b/actionmailer/CHANGELOG @@ -1,13 +1,16 @@ *Mail Integration -* Mail does not have "quoted_body", "quoted_subject" etc. All of these are accessed via body.encoded, subject.encoded etc +* Mail does not have "quoted_body", "quoted_subject" etc. All of these are accessed via body.encoded, + subject.encoded etc -* Every part of a Mail object returns an object, never a string. So Mail.body returns a Mail::Body class object, need to call #encoded or #decoded to get the string you want +* Every part of a Mail object returns an object, never a string. So Mail.body returns a Mail::Body + class object, need to call #encoded or #decoded to get the string you want * Mail::Message#set_content_type does not exist, it is simply Mail::Message#content_type -* Every mail message gets a unique message_id unless you specify one, had to change all the tests that check for - equality with expected.encoded == actual.encoded to first replace their message_ids with control values +* Every mail message gets a unique message_id unless you specify one, had to change all the tests that + check for equality with expected.encoded == actual.encoded to first replace their message_ids with + control values * Mail now has a proper concept of parts, remove the ActionMailer::Part and ActionMailer::PartContainer classes @@ -20,9 +23,6 @@ * There is no idea of a "sub_head" in Mail. A part is just a Message with some extra functionality, so it just has a "header" like a normal mail message - -* When you want to add a nested part, you now need to use "add_part(params)" instead of "part(params)" This - creates a Mail gem Part object *2.3.2 [Final] (March 15, 2009)* diff --git a/actionmailer/lib/action_mailer.rb b/actionmailer/lib/action_mailer.rb index 3eb385d3b0..15555af19e 100644 --- a/actionmailer/lib/action_mailer.rb +++ b/actionmailer/lib/action_mailer.rb @@ -40,7 +40,6 @@ module ActionMailer autoload :Quoting, 'action_mailer/quoting' autoload :TestCase, 'action_mailer/test_case' autoload :TestHelper, 'action_mailer/test_helper' - autoload :Utils, 'action_mailer/utils' end @@ -54,5 +53,5 @@ end autoload :MailHelper, 'action_mailer/mail_helper' -gem 'mail', '>= 1.2.8' -require 'mail' \ No newline at end of file +gem 'mail', '>= 1.2.9' +require 'mail' diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 3d0ac49c34..bf5e15e0e5 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -251,7 +251,7 @@ module ActionMailer #:nodoc: # and appear last in the mime encoded message. You can also pick a different order from inside a method with # +implicit_parts_order+. class Base - include AdvAttrAccessor, Quoting, Utils + include AdvAttrAccessor, Quoting include AbstractController::RenderingController include AbstractController::LocalizedCache @@ -617,11 +617,11 @@ module ActionMailer #:nodoc: if @parts.empty? main_type, sub_type = split_content_type(real_content_type) m.content_type([main_type, sub_type, ctype_attrs]) - m.body = normalize_new_lines(body) + m.body = body elsif @parts.size == 1 && @parts.first.parts.empty? main_type, sub_type = split_content_type(real_content_type) m.content_type([main_type, sub_type, ctype_attrs]) - m.body = normalize_new_lines(@parts.first.body) + m.body = @parts.first.body.encoded else @parts.each do |p| m.add_part(p) diff --git a/actionmailer/lib/action_mailer/utils.rb b/actionmailer/lib/action_mailer/utils.rb deleted file mode 100644 index 26d2e60aaf..0000000000 --- a/actionmailer/lib/action_mailer/utils.rb +++ /dev/null @@ -1,7 +0,0 @@ -module ActionMailer - module Utils #:nodoc: - def normalize_new_lines(text) - text.to_s.gsub(/\r\n?/, "\n") - end - end -end -- cgit v1.2.3 From cc391c30227564032398f24417bba21ab1a3d66a Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Mon, 23 Nov 2009 20:53:07 +1100 Subject: Deprecating attachment :body => 'string' in favour of attachment :data => 'string' --- actionmailer/lib/action_mailer/base.rb | 6 +++++- actionmailer/test/mail_service_test.rb | 10 +++++----- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index bf5e15e0e5..af3ef877b2 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -386,7 +386,11 @@ module ActionMailer #:nodoc: params = { :content_type => params } if String === params params = { :content_disposition => "attachment", :content_transfer_encoding => "base64" }.merge(params) - params[:data] = params.delete(:body) if params[:body] + if params[:body] + ActiveSupport::Deprecation.warn('attachment :body => "string" is deprecated. To set the body of an attachment ' << + 'please use :data instead, like attachment :data => "string".', caller[0,10]) + params[:data] = params.delete(:body) + end part(params, &block) end diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index c4d664d7e5..3099dddf87 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -9,7 +9,7 @@ class FunkyPathMailer < ActionMailer::Base subject "This path has dots" from "Chad Fowler " attachment :content_type => "text/plain", - :body => "dots dots dots..." + :data => "dots dots dots..." end end @@ -144,7 +144,7 @@ class TestMailer < ActionMailer::Base end attachment :content_type => "image/jpeg", :filename => File.join(File.dirname(__FILE__), "fixtures", "attachments", "foo.jpg"), - :body => "123456789" + :data => "123456789" render :text => "plain text default" end @@ -232,7 +232,7 @@ class TestMailer < ActionMailer::Base p.part :content_type => "text/html", :body => "test HTML
\nline #2" end - attachment :content_type => "application/octet-stream", :filename => "test.txt", :body => "test abcdefghijklmnopqstuvwxyz" + attachment :content_type => "application/octet-stream", :filename => "test.txt", :data => "test abcdefghijklmnopqstuvwxyz" end def nested_multipart_with_body(recipient) @@ -252,7 +252,7 @@ class TestMailer < ActionMailer::Base from "test@example.com" content_type "multipart/related" part :content_type => "text/html", :body => 'yo' - attachment :content_type => "image/jpeg", :filename => File.join(File.dirname(__FILE__), "fixtures", "attachments", "test.jpg"), :body => "i am not a real picture", :headers => { 'Content-ID' => '' } + attachment :content_type => "image/jpeg", :filename => File.join(File.dirname(__FILE__), "fixtures", "attachments", "test.jpg"), :data => "i am not a real picture", :headers => { 'Content-ID' => '' } end def unnamed_attachment(recipient) @@ -261,7 +261,7 @@ class TestMailer < ActionMailer::Base from "test@example.com" content_type "multipart/mixed" part :content_type => "text/plain", :body => "hullo" - attachment :content_type => "application/octet-stream", :body => "test abcdefghijklmnopqstuvwxyz" + attachment :content_type => "application/octet-stream", :data => "test abcdefghijklmnopqstuvwxyz" end def headers_with_nonalpha_chars(recipient) -- cgit v1.2.3 From 906e308220785b0c57c78462b05eb1552387a9b8 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Mon, 23 Nov 2009 20:58:22 +1100 Subject: Fixed up incompatible encoding problem for Ruby 1.9 in test suite --- actionmailer/test/mail_service_test.rb | 12 +++++++++--- actionmailer/test/quoting_test.rb | 4 ++++ 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index 3099dddf87..c49657acd7 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -1020,9 +1020,15 @@ EOF attachment = mail.attachments.last expected = "01 Quien Te Dij\212at. Pitbull.mp3" - expected.force_encoding(Encoding::ASCII_8BIT) if expected.respond_to?(:force_encoding) - - assert_equal expected, attachment.original_filename + + if expected.respond_to?(:force_encoding) + result = attachment.original_filename.dup + expected.force_encoding(Encoding::ASCII_8BIT) + result.force_encoding(Encoding::ASCII_8BIT) + assert_equal expected, result + else + assert_equal expected, attachment.original_filename + end end def test_decode_message_with_unknown_charset diff --git a/actionmailer/test/quoting_test.rb b/actionmailer/test/quoting_test.rb index 5319d2c6e8..a5deecf263 100644 --- a/actionmailer/test/quoting_test.rb +++ b/actionmailer/test/quoting_test.rb @@ -58,6 +58,10 @@ class QuotingTest < Test::Unit::TestCase CODE unquoted = Mail::Encodings.unquote_and_convert_to(result, nil) + + unquoted.force_encoding(Encoding::ASCII_8BIT) if unquoted.respond_to?(:force_encoding) + original.force_encoding(Encoding::ASCII_8BIT) if original.respond_to?(:force_encoding) + assert_equal unquoted, original end -- cgit v1.2.3 From 2e453d930d5c0ffaaeed69a5c881d5fbb2df1bfa Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Tue, 24 Nov 2009 09:33:05 +1100 Subject: Changed deprecation to use ActiveSupport::Deprecation --- actionmailer/lib/action_mailer/base.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index af3ef877b2..9876b88ecd 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -372,8 +372,9 @@ module ActionMailer #:nodoc: def part(params) params = {:content_type => params} if String === params if custom_headers = params.delete(:headers) - STDERR.puts("Passing custom headers with :headers => {} is deprecated. Please just pass in custom headers directly.") - params = params.merge(custom_headers) + ActiveSupport::Deprecation.warn('Passing custom headers with :headers => {} is deprecated. ' << + 'Please just pass in custom headers directly.', caller[0,10]) + params.merge!(custom_headers) end part = Mail::Part.new(params) yield part if block_given? -- cgit v1.2.3 From 3a72923e27195983d37bdb39ef26b29cf03d3483 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Tue, 24 Nov 2009 09:38:00 +1100 Subject: Change require mail version to 1.3.0 --- actionmailer/lib/action_mailer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionmailer') diff --git a/actionmailer/lib/action_mailer.rb b/actionmailer/lib/action_mailer.rb index 15555af19e..41ed399308 100644 --- a/actionmailer/lib/action_mailer.rb +++ b/actionmailer/lib/action_mailer.rb @@ -53,5 +53,5 @@ end autoload :MailHelper, 'action_mailer/mail_helper' -gem 'mail', '>= 1.2.9' +gem 'mail', '>= 1.3.0' require 'mail' -- cgit v1.2.3