From 05f27761a23f3e939f35e4fb2d3c40f150dee49b Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Tue, 2 Mar 2010 22:55:09 -0800 Subject: Fix action_mailer tests --- actionmailer/test/log_subscriber_test.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'actionmailer') diff --git a/actionmailer/test/log_subscriber_test.rb b/actionmailer/test/log_subscriber_test.rb index edd7c84d29..c08c34b4a2 100644 --- a/actionmailer/test/log_subscriber_test.rb +++ b/actionmailer/test/log_subscriber_test.rb @@ -4,7 +4,11 @@ require "action_mailer/railties/log_subscriber" class AMLogSubscriberTest < ActionMailer::TestCase include Rails::LogSubscriber::TestHelper - Rails::LogSubscriber.add(:action_mailer, ActionMailer::Railties::LogSubscriber.new) + + def setup + super + Rails::LogSubscriber.add(:action_mailer, ActionMailer::Railties::LogSubscriber.new) + end class TestMailer < ActionMailer::Base def basic -- cgit v1.2.3 From cd5ec4744dec9f8a443d1318bfafc9cf02752819 Mon Sep 17 00:00:00 2001 From: Pavel Golubeff Date: Wed, 3 Mar 2010 09:54:52 +0100 Subject: Fix quoting regexp encoding in ActionMailer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- actionmailer/lib/action_mailer/quoting.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionmailer') diff --git a/actionmailer/lib/action_mailer/quoting.rb b/actionmailer/lib/action_mailer/quoting.rb index 70f636bf69..2b55c0f0ab 100644 --- a/actionmailer/lib/action_mailer/quoting.rb +++ b/actionmailer/lib/action_mailer/quoting.rb @@ -22,7 +22,7 @@ module ActionMailer # A quick-and-dirty regexp for determining whether a string contains any # characters that need escaping. if !defined?(CHARS_NEEDING_QUOTING) - CHARS_NEEDING_QUOTING = /[\000-\011\013\014\016-\037\177-\377]/ + CHARS_NEEDING_QUOTING = Regexp.new('[\000-\011\013\014\016-\037\177-\377]', nil, 'n') end # Quote the given text if it contains any "illegal" characters -- cgit v1.2.3 From ad2e6ee4ec5cc6c6bc5f11bfb875e582dbe55468 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Thu, 4 Mar 2010 01:01:21 -0800 Subject: Fix a bunch of failing AP / AM specs created from the previous AbstractController configuration refactor. --- actionmailer/test/old_base/asset_host_test.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/test/old_base/asset_host_test.rb b/actionmailer/test/old_base/asset_host_test.rb index aa9cfd88dd..36f0afcfd6 100644 --- a/actionmailer/test/old_base/asset_host_test.rb +++ b/actionmailer/test/old_base/asset_host_test.rb @@ -21,13 +21,17 @@ class AssetHostTest < Test::Unit::TestCase end def test_asset_host_as_string - ActionController::Base.asset_host = "http://www.example.com" + ActionMailer::Base.configure do |c| + c.asset_host = "http://www.example.com" + c.assets_dir = File.dirname(__FILE__) + end + mail = AssetHostMailer.email_with_asset assert_equal "\"Somelogo\"", mail.body.to_s.strip end def test_asset_host_as_one_arguement_proc - ActionController::Base.asset_host = Proc.new { |source| + AssetHostMailer.config.asset_host = Proc.new { |source| if source.starts_with?('/images') "http://images.example.com" else -- cgit v1.2.3 From 05b9382e292d8b5aeee00304876c1f4e9fc87de5 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Thu, 4 Mar 2010 01:12:16 -0800 Subject: Update the ActionMailer tests to run off of the latest ActionController config refactor --- actionmailer/test/old_base/asset_host_test.rb | 9 ++++----- actionmailer/test/old_base/url_test.rb | 4 ++++ 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/test/old_base/asset_host_test.rb b/actionmailer/test/old_base/asset_host_test.rb index 36f0afcfd6..75fe2a6168 100644 --- a/actionmailer/test/old_base/asset_host_test.rb +++ b/actionmailer/test/old_base/asset_host_test.rb @@ -14,6 +14,10 @@ class AssetHostTest < Test::Unit::TestCase set_delivery_method :test ActionMailer::Base.perform_deliveries = true ActionMailer::Base.deliveries.clear + AssetHostMailer.configure do |c| + c.asset_host = "http://www.example.com" + c.assets_dir = '' + end end def teardown @@ -21,11 +25,6 @@ class AssetHostTest < Test::Unit::TestCase end def test_asset_host_as_string - ActionMailer::Base.configure do |c| - c.asset_host = "http://www.example.com" - c.assets_dir = File.dirname(__FILE__) - end - mail = AssetHostMailer.email_with_asset assert_equal "\"Somelogo\"", mail.body.to_s.strip end diff --git a/actionmailer/test/old_base/url_test.rb b/actionmailer/test/old_base/url_test.rb index a719248599..60740d6b0b 100644 --- a/actionmailer/test/old_base/url_test.rb +++ b/actionmailer/test/old_base/url_test.rb @@ -13,6 +13,10 @@ end class TestMailer < ActionMailer::Base default_url_options[:host] = 'www.basecamphq.com' + configure do |c| + c.assets_dir = '' # To get the tests to pass + end + def signed_up_with_url(recipient) @recipients = recipient @subject = "[Signed up] Welcome #{recipient}" -- cgit v1.2.3 From 46bf2f04a87c56826963958eaf370d9262526af0 Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Thu, 4 Mar 2010 17:44:16 -0800 Subject: Fixed a broken AM test. I'm unsure how this passed before. --- actionmailer/test/old_base/asset_host_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionmailer') diff --git a/actionmailer/test/old_base/asset_host_test.rb b/actionmailer/test/old_base/asset_host_test.rb index 75fe2a6168..0ec0242f55 100644 --- a/actionmailer/test/old_base/asset_host_test.rb +++ b/actionmailer/test/old_base/asset_host_test.rb @@ -42,7 +42,7 @@ class AssetHostTest < Test::Unit::TestCase end def test_asset_host_as_two_arguement_proc - ActionController::Base.asset_host = Proc.new {|source,request| + ActionController::Base.config.asset_host = Proc.new {|source,request| if request && request.ssl? "https://www.example.com" else -- cgit v1.2.3 From deb00bcb8cf88eb6420282c9af0af64fb69aeed4 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Thu, 4 Mar 2010 22:41:39 -0500 Subject: Read Rails version from a file instead of modifying the load path and doing requires Signed-off-by: Jeremy Kemper --- actionmailer/actionmailer.gemspec | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/actionmailer.gemspec b/actionmailer/actionmailer.gemspec index fc7f3f1e5f..3c9ffd1749 100644 --- a/actionmailer/actionmailer.gemspec +++ b/actionmailer/actionmailer.gemspec @@ -1,10 +1,9 @@ -$:.unshift "lib" -require "action_mailer/version" +version = File.read("../RAILS_VERSION").strip Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = 'actionmailer' - s.version = ActionMailer::VERSION::STRING + s.version = version s.summary = 'Email composition, delivery, and receiving framework (part of Rails).' s.description = 'Email on Rails. Compose, deliver, receive, and test emails using the familiar controller/view pattern. First-class support for multipart email and attachments.' s.required_ruby_version = '>= 1.8.7' @@ -20,7 +19,7 @@ Gem::Specification.new do |s| s.has_rdoc = true - s.add_dependency('actionpack', "= #{ActionMailer::VERSION::STRING}") + s.add_dependency('actionpack', version) s.add_dependency('mail', '~> 2.1.3') s.add_dependency('text-format', '~> 1.0.0') end -- cgit v1.2.3 From 4bc2cbc3cfa231b3dea0dce38a6fa2723c7ed94d Mon Sep 17 00:00:00 2001 From: Stefan Penner Date: Sat, 6 Mar 2010 13:30:25 -0600 Subject: Load RAILS_VERSION relative to the gemspec file. --- actionmailer/actionmailer.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionmailer') diff --git a/actionmailer/actionmailer.gemspec b/actionmailer/actionmailer.gemspec index 3c9ffd1749..a7a2599105 100644 --- a/actionmailer/actionmailer.gemspec +++ b/actionmailer/actionmailer.gemspec @@ -1,4 +1,4 @@ -version = File.read("../RAILS_VERSION").strip +version = File.read(File.expand_path("../../RAILS_VERSION", __FILE__)).strip Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY -- cgit v1.2.3 From 39d6f9e112f2320d8c2006ee3bcc160cfa761d0a Mon Sep 17 00:00:00 2001 From: wycats Date: Sun, 7 Mar 2010 06:24:30 -0800 Subject: Make many parts of Rails lazy. In order to facilitate this, add lazy_load_hooks.rb, which allows us to declare code that should be run at some later time. For instance, this allows us to defer requiring ActiveRecord::Base at boot time purely to apply configuration. Instead, we register a hook that should apply configuration once ActiveRecord::Base is loaded. With these changes, brings down total boot time of a new app to 300ms in production and 400ms in dev. TODO: rename base_hook --- actionmailer/lib/action_mailer.rb | 1 + actionmailer/lib/action_mailer/base.rb | 2 ++ actionmailer/lib/action_mailer/railtie.rb | 10 ++++++---- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/lib/action_mailer.rb b/actionmailer/lib/action_mailer.rb index 7f5bcad922..43d73e71b9 100644 --- a/actionmailer/lib/action_mailer.rb +++ b/actionmailer/lib/action_mailer.rb @@ -34,6 +34,7 @@ require 'active_support/core_ext/array/uniq_by' require 'active_support/core_ext/module/attr_internal' require 'active_support/core_ext/module/delegation' require 'active_support/core_ext/string/inflections' +require 'active_support/lazy_load_hooks' module ActionMailer extend ::ActiveSupport::Autoload diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 48d6bbc8d9..246816e953 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -291,6 +291,8 @@ module ActionMailer #:nodoc: :parts_order => [ "text/plain", "text/enriched", "text/html" ] }.freeze + ActionMailer.run_base_hooks(self) + class << self def mailer_name diff --git a/actionmailer/lib/action_mailer/railtie.rb b/actionmailer/lib/action_mailer/railtie.rb index c5f18c7911..0182e48425 100644 --- a/actionmailer/lib/action_mailer/railtie.rb +++ b/actionmailer/lib/action_mailer/railtie.rb @@ -6,19 +6,21 @@ module ActionMailer railtie_name :action_mailer initializer "action_mailer.url_for", :before => :load_environment_config do |app| - ActionMailer::Base.send(:include, app.routes.url_helpers) + ActionMailer.base_hook { include app.routes.url_helpers } end require "action_mailer/railties/log_subscriber" log_subscriber ActionMailer::Railties::LogSubscriber.new initializer "action_mailer.logger" do - ActionMailer::Base.logger ||= Rails.logger + ActionMailer.base_hook { self.logger ||= Rails.logger } end initializer "action_mailer.set_configs" do |app| - app.config.action_mailer.each do |k,v| - ActionMailer::Base.send "#{k}=", v + ActionMailer.base_hook do + app.config.action_mailer.each do |k,v| + send "#{k}=", v + end end end end -- cgit v1.2.3 From c7564d74e8a9b451f9fc78566ab0c734671f9612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 7 Mar 2010 19:41:58 +0100 Subject: Added template lookup responsible to hold all information used in template lookup. --- actionmailer/lib/action_mailer/base.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'actionmailer') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 48d6bbc8d9..14165e17a7 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -267,7 +267,6 @@ module ActionMailer #:nodoc: include AbstractController::Logger include AbstractController::Rendering - include AbstractController::DetailsCache include AbstractController::Layouts include AbstractController::Helpers include AbstractController::Translation -- cgit v1.2.3 From ffd8d753f171a33cb0f8dadaff7fc5ba12b8f6b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 8 Mar 2010 02:04:18 +0100 Subject: Move layout lookup to views. --- actionmailer/lib/action_mailer/base.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'actionmailer') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 14165e17a7..6937d76b5d 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -270,7 +270,6 @@ module ActionMailer #:nodoc: include AbstractController::Layouts include AbstractController::Helpers include AbstractController::Translation - include AbstractController::Compatibility helper ActionMailer::MailHelper -- cgit v1.2.3 From 36eb1a686c831d5a14998bb9ac7cc60efa363373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 8 Mar 2010 20:57:33 +0100 Subject: Bring AM up to date with new rendering stack. --- actionmailer/lib/action_mailer/base.rb | 12 +++++------- actionmailer/lib/action_mailer/old_api.rb | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 6937d76b5d..bc708cca56 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -614,14 +614,12 @@ module ActionMailer #:nodoc: def each_template(paths, name, &block) #:nodoc: Array(paths).each do |path| - self.class.view_paths.each do |load_paths| - templates = load_paths.find_all(name, {}, path) - templates = templates.uniq_by { |t| t.details[:formats] } + templates = lookup_context.find_all(name, path) - unless templates.empty? - templates.each(&block) - return - end + unless templates.empty? + templates = templates.uniq_by { |t| t.details[:formats] } + templates.each(&block) + return end end end diff --git a/actionmailer/lib/action_mailer/old_api.rb b/actionmailer/lib/action_mailer/old_api.rb index 941261a5b4..aeb653c5db 100644 --- a/actionmailer/lib/action_mailer/old_api.rb +++ b/actionmailer/lib/action_mailer/old_api.rb @@ -206,7 +206,7 @@ module ActionMailer if String === @body @parts.unshift create_inline_part(@body) elsif @parts.empty? || @parts.all? { |p| p.content_disposition =~ /^attachment/ } - self.class.view_paths.first.find_all(@template, {}, @mailer_name).each do |template| + lookup_context.find_all(@template, @mailer_name).each do |template| @parts << create_inline_part(render(:_template => template), template.mime_type) end -- cgit v1.2.3 From 00d6271d2b11a14065925529af0c1200406f8beb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 9 Mar 2010 13:12:11 +0100 Subject: Clean up the API required from ActionView::Template. --- actionmailer/lib/action_mailer/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionmailer') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index cd0c5bea53..ef3820ad67 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -617,9 +617,9 @@ module ActionMailer #:nodoc: def each_template(paths, name, &block) #:nodoc: Array(paths).each do |path| templates = lookup_context.find_all(name, path) + templates = templates.uniq_by { |t| t.formats } unless templates.empty? - templates = templates.uniq_by { |t| t.details[:formats] } templates.each(&block) return end -- cgit v1.2.3