Skip to content
Permalink
Browse files

ActionMailer should depend just on AbstractController.

  • Loading branch information...
josevalim committed Jan 29, 2010
1 parent 2960077 commit 3f8409193716669b9fa61ac74ae1c92cfde00785
@@ -24,9 +24,17 @@
actionpack_path = File.expand_path('../../../actionpack/lib', __FILE__)
$:.unshift(actionpack_path) if File.directory?(actionpack_path) && !$:.include?(actionpack_path)

require 'action_controller'
require 'abstract_controller'
require 'action_view'

# Common ActiveSupport usage in ActionMailer
require 'active_support/core_ext/class'
require 'active_support/core_ext/object/blank'
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'

module ActionMailer
extend ::ActiveSupport::Autoload

@@ -1,8 +1,3 @@
require 'active_support/core_ext/class'
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/array/uniq_by'
require 'active_support/core_ext/module/delegation'
require 'active_support/core_ext/string/inflections'
require 'mail'
require 'action_mailer/tmail_compat'
require 'action_mailer/collector'
@@ -254,7 +249,6 @@ class Base < AbstractController::Base
include AbstractController::LocalizedCache
include AbstractController::Layouts
include AbstractController::Helpers
include AbstractController::UrlFor
include AbstractController::Translation

helper ActionMailer::MailHelper
@@ -17,5 +17,9 @@ class Railtie < Rails::Railtie
ActionMailer::Base.send "#{k}=", v
end
end

initializer "action_mailer.url_for" do |app|
ActionMailer::Base.send(:include, ActionController::UrlFor) if defined?(ActionController)
end
end
end
@@ -415,6 +415,21 @@ def different_layout(layout_name='')
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
assert_equal(0, email.parts.size)
@@ -456,22 +471,8 @@ def different_layout(layout_name='')
BaseMailer.expects(:welcome).returns(mail)
BaseMailer.welcome.deliver
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


# Rendering
test "that you can specify a different template" do
mail = BaseMailer.different_template('explicit_multipart_templates')
assert_equal("HTML Explicit Multipart Templates", mail.html_part.body.decoded)
@@ -1,9 +1,12 @@
require 'abstract_unit'
require 'action_controller'

class WelcomeController < ActionController::Base
end

class TestMailer < ActionMailer::Base
include ActionController::UrlFor

default_url_options[:host] = 'www.basecamphq.com'

def signed_up_with_url(recipient)
@@ -2,6 +2,7 @@
$:.unshift(activesupport_path) if File.directory?(activesupport_path) && !$:.include?(activesupport_path)

require 'active_support/ruby/shim'
require 'active_support/dependencies/autoload'
require 'active_support/core_ext/module/attr_internal'
require 'active_support/core_ext/module/delegation'

@@ -17,5 +18,4 @@ module AbstractController
autoload :Logger
autoload :Rendering
autoload :Translation
autoload :UrlFor
end

This file was deleted.

@@ -1,6 +1,5 @@
activesupport_path = File.expand_path('../../../activesupport/lib', __FILE__)
$:.unshift(activesupport_path) if File.directory?(activesupport_path) && !$:.include?(activesupport_path)
require 'active_support/ruby/shim'
require 'abstract_controller'
require 'action_dispatch'

module ActionController
extend ActiveSupport::Autoload
@@ -41,6 +40,7 @@ module ActionController
autoload :Integration, 'action_controller/deprecated/integration_test'
autoload :IntegrationTest, 'action_controller/deprecated/integration_test'
autoload :PerformanceTest, 'action_controller/deprecated/performance_test'
autoload :UrlWriter, 'action_controller/deprecated'
autoload :Routing, 'action_controller/deprecated'
autoload :TestCase, 'action_controller/test_case'

@@ -66,13 +66,11 @@ module ActionController
end

# All of these simply register additional autoloads
require 'abstract_controller'
require 'action_dispatch'
require 'action_view'
require 'action_controller/vendor/html-scanner'

# Common ActiveSupport usage in ActionController
require "active_support/concern"
require 'active_support/concern'
require 'active_support/core_ext/class/attribute_accessors'
require 'active_support/core_ext/load_error'
require 'active_support/core_ext/module/attr_internal'
@@ -81,5 +81,13 @@ def self.filter_parameter_logging(*args, &block)
filter << block if block
filter
end

protected

# Overwrite url rewriter to use request.
def _url_rewriter
return ActionController::UrlRewriter unless request
@_url_rewriter ||= ActionController::UrlRewriter.new(request, params)
end
end
end
@@ -2,4 +2,4 @@
ActionController::AbstractResponse = ActionController::Response = ActionDispatch::Response
ActionController::Routing = ActionDispatch::Routing
ActionController::Routing::Routes = ActionDispatch::Routing::RouteSet.new
ActionController::UrlWriter = AbstractController::UrlFor
ActionController::UrlWriter = ActionController::UrlFor

0 comments on commit 3f84091

Please sign in to comment.
You can’t perform that action at this time.