From 2a12686832fbcf0566454904a5d733998506bf56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 12 Mar 2010 14:25:10 +0100 Subject: Allow anything that responds to render to be given as :template and use find_template instead of find in views. --- actionmailer/lib/action_mailer/base.rb | 2 +- actionmailer/lib/action_mailer/old_api.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index ef3820ad67..f94e23fe05 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -605,7 +605,7 @@ module ActionMailer #:nodoc: each_template(templates_path, templates_name) do |template| responses << { - :body => render(:_template => template), + :body => render(:template => template), :content_type => template.mime_type.to_s } end diff --git a/actionmailer/lib/action_mailer/old_api.rb b/actionmailer/lib/action_mailer/old_api.rb index aeb653c5db..fb4b6701dd 100644 --- a/actionmailer/lib/action_mailer/old_api.rb +++ b/actionmailer/lib/action_mailer/old_api.rb @@ -207,7 +207,7 @@ module ActionMailer @parts.unshift create_inline_part(@body) elsif @parts.empty? || @parts.all? { |p| p.content_disposition =~ /^attachment/ } lookup_context.find_all(@template, @mailer_name).each do |template| - @parts << create_inline_part(render(:_template => template), template.mime_type) + @parts << create_inline_part(render(:template => template), template.mime_type) end if @parts.size > 1 -- cgit v1.2.3 From f2c0a353aef41a6df2de8e1fe3eaa3d8bbd8a6dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 12 Mar 2010 20:39:53 +0100 Subject: Finish cleaning up rendering stack from views and move assigns evaluation to controller (so plugins and/or controllers can overwrite just one method). --- actionmailer/test/base_test.rb | 2 ++ actionmailer/test/old_base/mail_service_test.rb | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index c1cf1f0157..f5fd12a6b0 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -2,6 +2,8 @@ require 'abstract_unit' class BaseTest < ActiveSupport::TestCase + # TODO Add some tests for implicity layout render and url helpers + # so we can get rid of old base tests altogether with old base. class BaseMailer < ActionMailer::Base self.mailer_name = "base_mailer" diff --git a/actionmailer/test/old_base/mail_service_test.rb b/actionmailer/test/old_base/mail_service_test.rb index 70dafaf33c..6d0b2c53a3 100644 --- a/actionmailer/test/old_base/mail_service_test.rb +++ b/actionmailer/test/old_base/mail_service_test.rb @@ -444,9 +444,6 @@ class ActionMailerTest < Test::Unit::TestCase expected.from = "system@loudthinking.com" expected.date = Time.local(2004, 12, 12) - # Stub the render method so no alternative renderers need be present. - ActionView::Base.any_instance.stubs(:render).returns("Hello there, \n\nMr. #{@recipient}") - # Now that the template is registered, there should be one part. The text/plain part. created = nil assert_nothing_raised { created = TestMailer.custom_templating_extension(@recipient) } -- cgit v1.2.3 From cd9ffd11e13ef6e62eba2cbd5c3760ff04132820 Mon Sep 17 00:00:00 2001 From: wycats Date: Tue, 16 Mar 2010 23:24:00 -0700 Subject: Eliminate warnings for AM on 1.8 --- actionmailer/lib/action_mailer/old_api.rb | 3 --- actionmailer/test/abstract_unit.rb | 21 ++++++++++++++++++++- actionmailer/test/old_base/url_test.rb | 2 ++ 3 files changed, 22 insertions(+), 4 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/lib/action_mailer/old_api.rb b/actionmailer/lib/action_mailer/old_api.rb index fb4b6701dd..4581b31bb9 100644 --- a/actionmailer/lib/action_mailer/old_api.rb +++ b/actionmailer/lib/action_mailer/old_api.rb @@ -31,9 +31,6 @@ module ActionMailer # replies to this message. adv_attr_accessor :reply_to - # Specify additional headers to be added to the message. - adv_attr_accessor :headers - # Specify the order in which parts should be sorted, based on content-type. # This defaults to the value for the +default_implicit_parts_order+. adv_attr_accessor :implicit_parts_order diff --git a/actionmailer/test/abstract_unit.rb b/actionmailer/test/abstract_unit.rb index 16fef3a9a4..ea15709b45 100644 --- a/actionmailer/test/abstract_unit.rb +++ b/actionmailer/test/abstract_unit.rb @@ -1,4 +1,23 @@ -require File.expand_path('../../../load_paths', __FILE__) +# Pathname has a warning, so require it first while silencing +# warnings to shut it up. +# +# Also, in 1.9, Bundler creates warnings due to overriding +# Rubygems methods +begin + old, $VERBOSE = $VERBOSE, nil + require 'pathname' + require File.expand_path('../../../load_paths', __FILE__) +ensure + $VERBOSE = old +end + + +require 'active_support/core_ext/kernel/reporting' +silence_warnings do + # These external dependencies have warnings :/ + require 'text/format' + require 'mail' +end lib = File.expand_path("#{File.dirname(__FILE__)}/../lib") $:.unshift(lib) unless $:.include?('lib') || $:.include?(lib) diff --git a/actionmailer/test/old_base/url_test.rb b/actionmailer/test/old_base/url_test.rb index 60740d6b0b..c98c3cde3a 100644 --- a/actionmailer/test/old_base/url_test.rb +++ b/actionmailer/test/old_base/url_test.rb @@ -31,6 +31,8 @@ class TestMailer < ActionMailer::Base attr_accessor :received_body end + remove_method :receive + def receive(mail) self.class.received_body = mail.body end -- cgit v1.2.3 From a5587efc1903fd27d4b179753aa6e139445ad18c Mon Sep 17 00:00:00 2001 From: wycats Date: Wed, 17 Mar 2010 00:15:55 -0700 Subject: Remove some 1.9 warnings (resulting in some fixed bugs). Remaining AM warnings are in dependencies. --- actionmailer/test/old_base/url_test.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'actionmailer') diff --git a/actionmailer/test/old_base/url_test.rb b/actionmailer/test/old_base/url_test.rb index c98c3cde3a..c09e05f942 100644 --- a/actionmailer/test/old_base/url_test.rb +++ b/actionmailer/test/old_base/url_test.rb @@ -28,6 +28,8 @@ class TestMailer < ActionMailer::Base end class < Date: Wed, 17 Mar 2010 21:43:01 -0700 Subject: Kill nonexistent method removal --- actionmailer/test/old_base/url_test.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/test/old_base/url_test.rb b/actionmailer/test/old_base/url_test.rb index c09e05f942..c98c3cde3a 100644 --- a/actionmailer/test/old_base/url_test.rb +++ b/actionmailer/test/old_base/url_test.rb @@ -28,8 +28,6 @@ class TestMailer < ActionMailer::Base end class < Date: Wed, 17 Mar 2010 22:27:34 -0700 Subject: Fix broken test due to constant collision --- actionmailer/test/fixtures/test_mailer/signed_up_with_url.erb | 5 ----- .../test/fixtures/url_test_mailer/signed_up_with_url.erb | 5 +++++ actionmailer/test/old_base/url_test.rb | 10 ++++------ 3 files changed, 9 insertions(+), 11 deletions(-) delete mode 100644 actionmailer/test/fixtures/test_mailer/signed_up_with_url.erb create mode 100644 actionmailer/test/fixtures/url_test_mailer/signed_up_with_url.erb (limited to 'actionmailer') diff --git a/actionmailer/test/fixtures/test_mailer/signed_up_with_url.erb b/actionmailer/test/fixtures/test_mailer/signed_up_with_url.erb deleted file mode 100644 index 4c5806d30d..0000000000 --- a/actionmailer/test/fixtures/test_mailer/signed_up_with_url.erb +++ /dev/null @@ -1,5 +0,0 @@ -Hello there, - -Mr. <%= @recipient %>. Please see our greeting at <%= @welcome_url %> <%= welcome_url %> - -<%= image_tag "somelogo.png" %> \ No newline at end of file diff --git a/actionmailer/test/fixtures/url_test_mailer/signed_up_with_url.erb b/actionmailer/test/fixtures/url_test_mailer/signed_up_with_url.erb new file mode 100644 index 0000000000..4c5806d30d --- /dev/null +++ b/actionmailer/test/fixtures/url_test_mailer/signed_up_with_url.erb @@ -0,0 +1,5 @@ +Hello there, + +Mr. <%= @recipient %>. Please see our greeting at <%= @welcome_url %> <%= welcome_url %> + +<%= image_tag "somelogo.png" %> \ No newline at end of file diff --git a/actionmailer/test/old_base/url_test.rb b/actionmailer/test/old_base/url_test.rb index c98c3cde3a..0b8bef233b 100644 --- a/actionmailer/test/old_base/url_test.rb +++ b/actionmailer/test/old_base/url_test.rb @@ -10,7 +10,7 @@ class ActionMailer::Base include AppRoutes.url_helpers end -class TestMailer < ActionMailer::Base +class UrlTestMailer < ActionMailer::Base default_url_options[:host] = 'www.basecamphq.com' configure do |c| @@ -31,8 +31,6 @@ class TestMailer < ActionMailer::Base attr_accessor :received_body end - remove_method :receive - def receive(mail) self.class.received_body = mail.body end @@ -67,7 +65,7 @@ class ActionMailerUrlTest < Test::Unit::TestCase end def test_signed_up_with_url - TestMailer.delivery_method = :test + UrlTestMailer.delivery_method = :test AppRoutes.draw do |map| map.connect ':controller/:action/:id' @@ -82,14 +80,14 @@ class ActionMailerUrlTest < Test::Unit::TestCase expected.date = Time.local(2004, 12, 12) created = nil - assert_nothing_raised { created = TestMailer.signed_up_with_url(@recipient) } + assert_nothing_raised { created = UrlTestMailer.signed_up_with_url(@recipient) } assert_not_nil created expected.message_id = '<123@456>' created.message_id = '<123@456>' assert_equal expected.encoded, created.encoded - assert_nothing_raised { TestMailer.signed_up_with_url(@recipient).deliver } + assert_nothing_raised { UrlTestMailer.signed_up_with_url(@recipient).deliver } assert_not_nil ActionMailer::Base.deliveries.first delivered = ActionMailer::Base.deliveries.first -- cgit v1.2.3 From 41af6d9a78446a5219a321cf638945b1608cefd8 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 17 Mar 2010 22:27:48 -0700 Subject: Use Array.wrap not Array() --- actionmailer/lib/action_mailer/base.rb | 3 ++- actionmailer/lib/action_mailer/railties/log_subscriber.rb | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index f94e23fe05..0823120fc8 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -1,6 +1,7 @@ require 'mail' require 'action_mailer/tmail_compat' require 'action_mailer/collector' +require 'active_support/core_ext/array/wrap' module ActionMailer #:nodoc: # Action Mailer allows you to send email from your application using a mailer model and views. @@ -615,7 +616,7 @@ module ActionMailer #:nodoc: end def each_template(paths, name, &block) #:nodoc: - Array(paths).each do |path| + Array.wrap(paths).each do |path| templates = lookup_context.find_all(name, path) templates = templates.uniq_by { |t| t.formats } diff --git a/actionmailer/lib/action_mailer/railties/log_subscriber.rb b/actionmailer/lib/action_mailer/railties/log_subscriber.rb index d1b3dd33af..af76d807d0 100644 --- a/actionmailer/lib/action_mailer/railties/log_subscriber.rb +++ b/actionmailer/lib/action_mailer/railties/log_subscriber.rb @@ -1,8 +1,10 @@ +require 'active_support/core_ext/array/wrap' + module ActionMailer module Railties class LogSubscriber < Rails::LogSubscriber def deliver(event) - recipients = Array(event.payload[:to]).join(', ') + recipients = Array.wrap(event.payload[:to]).join(', ') info("\nSent mail to #{recipients} (%1.fms)" % event.duration) debug(event.payload[:mail]) end @@ -17,4 +19,4 @@ module ActionMailer end end end -end \ No newline at end of file +end -- cgit v1.2.3 From 9da153c2d39f52c55af59a42b8551763b5821900 Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Thu, 18 Mar 2010 11:30:31 -0700 Subject: Fix an error in isolated running of tests --- actionmailer/test/old_base/url_test.rb | 8 -------- 1 file changed, 8 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/test/old_base/url_test.rb b/actionmailer/test/old_base/url_test.rb index 0b8bef233b..17b383cc2a 100644 --- a/actionmailer/test/old_base/url_test.rb +++ b/actionmailer/test/old_base/url_test.rb @@ -26,14 +26,6 @@ class UrlTestMailer < ActionMailer::Base @recipient = recipient @welcome_url = url_for :host => "example.com", :controller => "welcome", :action => "greeting" end - - class < Date: Fri, 19 Mar 2010 17:20:15 +0100 Subject: Improve performance of the rendering stack by freezing formats as a sign that they shouldn't be further modified. --- actionmailer/lib/action_mailer/base.rb | 2 + actionmailer/lib/action_mailer/collector.rb | 11 ++-- actionmailer/lib/action_mailer/old_api.rb | 1 + actionmailer/test/base_test.rb | 58 ++++++++++++++-------- .../explicit_multipart_with_one_template.erb | 1 + actionmailer/test/old_base/mail_layout_test.rb | 22 -------- 6 files changed, 43 insertions(+), 52 deletions(-) create mode 100644 actionmailer/test/fixtures/base_mailer/explicit_multipart_with_one_template.erb (limited to 'actionmailer') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 0823120fc8..1dc2d92c43 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -605,6 +605,8 @@ module ActionMailer #:nodoc: templates_name = headers.delete(:template_name) || action_name each_template(templates_path, templates_name) do |template| + self.formats = template.formats + responses << { :body => render(:template => template), :content_type => template.mime_type.to_s diff --git a/actionmailer/lib/action_mailer/collector.rb b/actionmailer/lib/action_mailer/collector.rb index 5431efccfe..bd4f76bbb6 100644 --- a/actionmailer/lib/action_mailer/collector.rb +++ b/actionmailer/lib/action_mailer/collector.rb @@ -11,7 +11,6 @@ module ActionMailer #:nodoc: @context = context @responses = [] @default_render = block - @default_formats = context.formats end def any(*args, &block) @@ -21,16 +20,12 @@ module ActionMailer #:nodoc: end alias :all :any - def custom(mime, options={}, &block) + def custom(mime, options={}) options.reverse_merge!(:content_type => mime.to_s) @context.formats = [mime.to_sym] - options[:body] = if block - block.call - else - @default_render.call - end + @context.formats.freeze + options[:body] = block_given? ? yield : @default_render.call @responses << options - @context.formats = @default_formats end end end \ No newline at end of file diff --git a/actionmailer/lib/action_mailer/old_api.rb b/actionmailer/lib/action_mailer/old_api.rb index 4581b31bb9..c7f341d46c 100644 --- a/actionmailer/lib/action_mailer/old_api.rb +++ b/actionmailer/lib/action_mailer/old_api.rb @@ -204,6 +204,7 @@ module ActionMailer @parts.unshift create_inline_part(@body) elsif @parts.empty? || @parts.all? { |p| p.content_disposition =~ /^attachment/ } lookup_context.find_all(@template, @mailer_name).each do |template| + self.formats = template.formats @parts << create_inline_part(render(:template => template), template.mime_type) end diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index f5fd12a6b0..6f274c11df 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -74,13 +74,20 @@ class BaseTest < ActiveSupport::TestCase end end - def custom_block(include_html=false) + def explicit_multipart_with_options(include_html = false) mail do |format| format.text(:content_transfer_encoding => "base64"){ render "welcome" } format.html{ render "welcome" } if include_html end end + def explicit_multipart_with_one_template(hash = {}) + mail(hash) do |format| + format.html + format.text + end + end + def implicit_different_template(template_name='') mail(:template_name => template_name) end @@ -148,6 +155,13 @@ class BaseTest < ActiveSupport::TestCase assert_equal("Hello there", email.body.encoded) end + test "should set template content type if mail has only one part" do + mail = BaseMailer.html_only + assert_equal('text/html', mail.mime_type) + mail = BaseMailer.plain_text_only + assert_equal('text/plain', mail.mime_type) + end + # Custom headers test "custom headers" do email = BaseMailer.welcome @@ -162,7 +176,7 @@ class BaseTest < ActiveSupport::TestCase assert_equal('1234@mikel.me.com', mail['In-Reply-To'].decoded) end - test "can pass random headers in as a hash" do + test "can pass random headers in as a hash to headers" do hash = {'X-Special-Domain-Specific-Header' => "SecretValue", 'In-Reply-To' => '1234@mikel.me.com' } mail = BaseMailer.welcome_with_headers(hash) @@ -366,6 +380,11 @@ class BaseTest < ActiveSupport::TestCase assert_equal("HTML Explicit Multipart", email.parts[1].body.encoded) end + test "explicit multipart have a boundary" do + mail = BaseMailer.explicit_multipart + assert_not_nil(mail.content_type_parameters[:boundary]) + end + test "explicit multipart does not sort order" do order = ["text/html", "text/plain"] with_default BaseMailer, :parts_order => order do @@ -399,7 +418,7 @@ class BaseTest < ActiveSupport::TestCase assert_equal("TEXT Explicit Multipart Templates", email.parts[1].body.encoded) end - test "explicit multipart with any" do + test "explicit multipart with format.any" do email = BaseMailer.explicit_multipart_with_any assert_equal(2, email.parts.size) assert_equal("multipart/alternative", email.mime_type) @@ -409,8 +428,8 @@ class BaseTest < ActiveSupport::TestCase assert_equal("Format with any!", email.parts[1].body.encoded) end - test "explicit multipart with options" do - email = BaseMailer.custom_block(true) + test "explicit multipart with format(Hash)" do + email = BaseMailer.explicit_multipart_with_options(true) email.ready_to_send! assert_equal(2, email.parts.size) assert_equal("multipart/alternative", email.mime_type) @@ -420,28 +439,23 @@ class BaseTest < ActiveSupport::TestCase assert_equal("7bit", email.parts[1].content_transfer_encoding) end - test "explicit multipart should be multipart" do - mail = BaseMailer.explicit_multipart - assert_not_nil(mail.content_type_parameters[:boundary]) - end - - test "should set a content type if only has an html part" do - mail = BaseMailer.html_only - assert_equal('text/html', mail.mime_type) - end - - test "should set a content type if only has an plain text part" do - mail = BaseMailer.plain_text_only - assert_equal('text/plain', mail.mime_type) - end - - test "explicit multipart with one part is rendered as body" do - email = BaseMailer.custom_block + test "explicit multipart with one part is rendered as body and options are merged" do + email = BaseMailer.explicit_multipart_with_options assert_equal(0, email.parts.size) assert_equal("text/plain", email.mime_type) assert_equal("base64", email.content_transfer_encoding) end + test "explicit multipart with one template has the expected format" do + email = BaseMailer.explicit_multipart_with_one_template + assert_equal(2, email.parts.size) + assert_equal("multipart/alternative", email.mime_type) + assert_equal("text/html", email.parts[0].mime_type) + assert_equal("[:html]", email.parts[0].body.encoded) + assert_equal("text/plain", email.parts[1].mime_type) + assert_equal("[:text]", email.parts[1].body.encoded) + end + # Class level API with method missing test "should respond to action methods" do assert BaseMailer.respond_to?(:welcome) diff --git a/actionmailer/test/fixtures/base_mailer/explicit_multipart_with_one_template.erb b/actionmailer/test/fixtures/base_mailer/explicit_multipart_with_one_template.erb new file mode 100644 index 0000000000..8a69657b08 --- /dev/null +++ b/actionmailer/test/fixtures/base_mailer/explicit_multipart_with_one_template.erb @@ -0,0 +1 @@ +<%= self.formats.inspect %> \ No newline at end of file diff --git a/actionmailer/test/old_base/mail_layout_test.rb b/actionmailer/test/old_base/mail_layout_test.rb index 5679aa5a64..2c2daa0f28 100644 --- a/actionmailer/test/old_base/mail_layout_test.rb +++ b/actionmailer/test/old_base/mail_layout_test.rb @@ -69,47 +69,25 @@ class LayoutMailerTest < Test::Unit::TestCase def test_should_pickup_multipart_layout mail = AutoLayoutMailer.multipart - # CHANGED: content_type returns an object - # assert_equal "multipart/alternative", mail.content_type assert_equal "multipart/alternative", mail.mime_type assert_equal 2, mail.parts.size - # CHANGED: content_type returns an object - # assert_equal 'text/plain', mail.parts.first.content_type assert_equal 'text/plain', mail.parts.first.mime_type - - # CHANGED: body returns an object - # assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body.to_s - # CHANGED: content_type returns an object - # assert_equal 'text/html', mail.parts.last.content_type assert_equal 'text/html', mail.parts.last.mime_type - - # CHANGED: body returns an object - # assert_equal "Hello from layout text/html multipart", mail.parts.last.body assert_equal "Hello from layout text/html multipart", mail.parts.last.body.to_s end def test_should_pickup_multipartmixed_layout mail = AutoLayoutMailer.multipart("multipart/mixed") - # CHANGED: content_type returns an object - # assert_equal "multipart/mixed", mail.content_type assert_equal "multipart/mixed", mail.mime_type assert_equal 2, mail.parts.size - # CHANGED: content_type returns an object - # assert_equal 'text/plain', mail.parts.first.content_type assert_equal 'text/plain', mail.parts.first.mime_type - # CHANGED: body returns an object - # assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body.to_s - # CHANGED: content_type returns an object - # assert_equal 'text/html', mail.parts.last.content_type assert_equal 'text/html', mail.parts.last.mime_type - # CHANGED: body returns an object - # assert_equal "Hello from layout text/html multipart", mail.parts.last.body assert_equal "Hello from layout text/html multipart", mail.parts.last.body.to_s end -- cgit v1.2.3 From 1e4be20672252ac15a355589dd44bdd4623640c4 Mon Sep 17 00:00:00 2001 From: Evan Phoenix Date: Mon, 22 Mar 2010 09:50:45 -0700 Subject: Fix ActionMailer test issues * Don't depend so much no the message in a NameError * Reset the delivery method properly --- actionmailer/test/old_base/mail_service_test.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/test/old_base/mail_service_test.rb b/actionmailer/test/old_base/mail_service_test.rb index 6d0b2c53a3..e49307bfda 100644 --- a/actionmailer/test/old_base/mail_service_test.rb +++ b/actionmailer/test/old_base/mail_service_test.rb @@ -340,6 +340,8 @@ class ActionMailerTest < Test::Unit::TestCase @original_logger = TestMailer.logger @recipient = 'test@localhost' + + TestMailer.delivery_method = :test end def teardown @@ -1191,6 +1193,6 @@ class RespondToTest < Test::Unit::TestCase RespondToMailer.not_a_method end - assert_match(/undefined method.*not_a_method/, error.message) + assert_match(/method.*not_a_method/, error.message) end -end \ No newline at end of file +end -- cgit v1.2.3 From 395d6648ce7549f71dd0a76dc061e87f608aaaab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 26 Mar 2010 18:47:55 +0100 Subject: Move application configuration to the application configuration object, remove railtie_name and engine_name and allow to set the configuration object. --- actionmailer/lib/action_mailer/railtie.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/lib/action_mailer/railtie.rb b/actionmailer/lib/action_mailer/railtie.rb index 0182e48425..2703367fdb 100644 --- a/actionmailer/lib/action_mailer/railtie.rb +++ b/actionmailer/lib/action_mailer/railtie.rb @@ -3,14 +3,14 @@ require "rails" module ActionMailer class Railtie < Rails::Railtie - railtie_name :action_mailer + config.action_mailer = ActiveSupport::OrderedOptions.new initializer "action_mailer.url_for", :before => :load_environment_config do |app| ActionMailer.base_hook { include app.routes.url_helpers } end require "action_mailer/railties/log_subscriber" - log_subscriber ActionMailer::Railties::LogSubscriber.new + log_subscriber :action_mailer, ActionMailer::Railties::LogSubscriber.new initializer "action_mailer.logger" do ActionMailer.base_hook { self.logger ||= Rails.logger } -- cgit v1.2.3 From a09e99259c688a839bd5b4635da6f119dd1e0e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sat, 27 Mar 2010 20:51:25 +0100 Subject: Ensure details are frozen after @details_keys lookup. The implementation waits to freeze until the last required moment, to avoid duping hashes. --- actionmailer/lib/action_mailer/base.rb | 2 +- actionmailer/lib/action_mailer/collector.rb | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 1dc2d92c43..0519783d02 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -591,7 +591,7 @@ module ActionMailer #:nodoc: responses, parts_order = [], nil if block_given? - collector = ActionMailer::Collector.new(self) { render(action_name) } + collector = ActionMailer::Collector.new(lookup_context) { render(action_name) } yield(collector) parts_order = collector.responses.map { |r| r[:content_type] } responses = collector.responses diff --git a/actionmailer/lib/action_mailer/collector.rb b/actionmailer/lib/action_mailer/collector.rb index bd4f76bbb6..d03e085e83 100644 --- a/actionmailer/lib/action_mailer/collector.rb +++ b/actionmailer/lib/action_mailer/collector.rb @@ -22,8 +22,7 @@ module ActionMailer #:nodoc: def custom(mime, options={}) options.reverse_merge!(:content_type => mime.to_s) - @context.formats = [mime.to_sym] - @context.formats.freeze + @context.freeze_formats([mime.to_sym]) options[:body] = block_given? ? yield : @default_render.call @responses << options end -- cgit v1.2.3