diff options
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 7 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/railtie.rb | 2 | ||||
-rw-r--r-- | actionmailer/test/abstract_unit.rb | 9 | ||||
-rw-r--r-- | railties/test/application/initializers/frameworks_test.rb | 17 |
4 files changed, 22 insertions, 13 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 35ac0423a5..9cc00ca5a1 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -389,6 +389,8 @@ module ActionMailer #:nodoc: :parts_order => [ "text/plain", "text/enriched", "text/html" ] }.freeze + class_attribute :queue + class << self # Register one or more Observers which will be notified when mail is delivered. def register_observers(*observers) @@ -486,11 +488,6 @@ module ActionMailer #:nodoc: super end end - - def queue - Rails.queue - end - end attr_internal :message diff --git a/actionmailer/lib/action_mailer/railtie.rb b/actionmailer/lib/action_mailer/railtie.rb index 8679096735..1fa689de5b 100644 --- a/actionmailer/lib/action_mailer/railtie.rb +++ b/actionmailer/lib/action_mailer/railtie.rb @@ -19,6 +19,8 @@ module ActionMailer options.javascripts_dir ||= paths["public/javascripts"].first options.stylesheets_dir ||= paths["public/stylesheets"].first + options.queue ||= app.queue + # make sure readers methods get compiled options.asset_path ||= app.config.asset_path options.asset_host ||= app.config.asset_host diff --git a/actionmailer/test/abstract_unit.rb b/actionmailer/test/abstract_unit.rb index e5f9bae897..1167387def 100644 --- a/actionmailer/test/abstract_unit.rb +++ b/actionmailer/test/abstract_unit.rb @@ -27,14 +27,7 @@ ActionView::Template.register_template_handler :bak, lambda { |template| "Lame b FIXTURE_LOAD_PATH = File.expand_path('fixtures', File.dirname(__FILE__)) ActionMailer::Base.view_paths = FIXTURE_LOAD_PATH - -class ActionMailer::Base < AbstractController::Base - class << self - def queue - @queue ||= Rails::Queueing::Container.new(Rails::Queueing::SynchronousQueue.new) - end - end -end +ActionMailer::Base.queue = Rails::Queueing::SynchronousQueue.new class MockSMTP def self.deliveries diff --git a/railties/test/application/initializers/frameworks_test.rb b/railties/test/application/initializers/frameworks_test.rb index fbce97e1a9..1eb5fce384 100644 --- a/railties/test/application/initializers/frameworks_test.rb +++ b/railties/test/application/initializers/frameworks_test.rb @@ -50,6 +50,23 @@ module ApplicationTests assert_equal "test.rails", ActionMailer::Base.default_url_options[:host] end + test "uses the default queue for ActionMailer" do + require "#{app_path}/config/environment" + assert_kind_of Rails::Queueing::Container, ActionMailer::Base.queue + end + + test "allows me to configure queue for ActionMailer" do + app_file "config/environments/development.rb", <<-RUBY + AppTemplate::Application.configure do + Rails.queue[:mailer] = Rails::Queueing::TestQueue.new + config.action_mailer.queue = Rails.queue[:mailer] + end + RUBY + + require "#{app_path}/config/environment" + assert_kind_of Rails::Queueing::TestQueue, ActionMailer::Base.queue + end + test "does not include url helpers as action methods" do app_file "config/routes.rb", <<-RUBY AppTemplate::Application.routes.draw do |