diff options
Diffstat (limited to 'actionmailer')
-rw-r--r-- | actionmailer/CHANGELOG.md | 2 | ||||
-rw-r--r-- | actionmailer/MIT-LICENSE | 2 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer.rb | 3 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 15 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/collector.rb | 2 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/queued_message.rb | 37 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/railtie.rb | 2 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/test_case.rb | 7 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/test_helper.rb | 12 | ||||
-rw-r--r-- | actionmailer/lib/rails/generators/mailer/USAGE | 5 | ||||
-rw-r--r-- | actionmailer/test/abstract_unit.rb | 3 | ||||
-rw-r--r-- | actionmailer/test/base_test.rb | 13 | ||||
-rw-r--r-- | actionmailer/test/mailers/async_mailer.rb | 3 | ||||
-rw-r--r-- | actionmailer/test/spec_type_test.rb | 37 | ||||
-rw-r--r-- | actionmailer/test/test_test.rb | 144 |
15 files changed, 16 insertions, 271 deletions
diff --git a/actionmailer/CHANGELOG.md b/actionmailer/CHANGELOG.md index f182565974..43bfa536c1 100644 --- a/actionmailer/CHANGELOG.md +++ b/actionmailer/CHANGELOG.md @@ -33,8 +33,6 @@ * Raise an `ActionView::MissingTemplate` exception when no implicit template could be found. *Damien Mathieu* -* Asynchronously send messages via the Rails Queue *Brian Cardarella* - * Allow callbacks to be defined in mailers similar to `ActionController::Base`. You can configure default settings, headers, attachments, delivery settings or change delivery using `before_filter`, `after_filter` etc. *Justin S. Leitgeb* diff --git a/actionmailer/MIT-LICENSE b/actionmailer/MIT-LICENSE index 810daf856c..5c668d9624 100644 --- a/actionmailer/MIT-LICENSE +++ b/actionmailer/MIT-LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2012 David Heinemeier Hansson +Copyright (c) 2004-2013 David Heinemeier Hansson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/actionmailer/lib/action_mailer.rb b/actionmailer/lib/action_mailer.rb index a9642dc695..c45124be80 100644 --- a/actionmailer/lib/action_mailer.rb +++ b/actionmailer/lib/action_mailer.rb @@ -1,5 +1,5 @@ #-- -# Copyright (c) 2004-2012 David Heinemeier Hansson +# Copyright (c) 2004-2013 David Heinemeier Hansson # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -44,5 +44,4 @@ module ActionMailer autoload :MailHelper autoload :TestCase autoload :TestHelper - autoload :QueuedMessage end diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 4a61bac0a5..9ba606c045 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -1,10 +1,8 @@ require 'mail' -require 'action_mailer/queued_message' require 'action_mailer/collector' require 'active_support/core_ext/string/inflections' require 'active_support/core_ext/hash/except' require 'active_support/core_ext/module/anonymous' -require 'active_support/queueing' require 'action_mailer/log_subscriber' module ActionMailer @@ -361,8 +359,6 @@ module ActionMailer # # * <tt>deliveries</tt> - Keeps an array of all the emails sent out through the Action Mailer with # <tt>delivery_method :test</tt>. Most useful for unit and functional testing. - # - # * <tt>queue</> - The queue that will be used to deliver the mail. The queue should expect a job that responds to <tt>run</tt>. class Base < AbstractController::Base include DeliveryMethods abstract! @@ -389,9 +385,6 @@ module ActionMailer parts_order: [ "text/plain", "text/enriched", "text/html" ] }.freeze - class_attribute :queue - self.queue = ActiveSupport::SynchronousQueue.new - class << self # Register one or more Observers which will be notified when mail is delivered. def register_observers(*observers) @@ -483,8 +476,8 @@ module ActionMailer end def method_missing(method_name, *args) - if action_methods.include?(method_name.to_s) - QueuedMessage.new(queue, self, method_name, *args) + if respond_to?(method_name) + new(method_name, *args).message else super end @@ -537,7 +530,7 @@ module ActionMailer # The resulting Mail::Message will have the following in its header: # # X-Special-Domain-Specific-Header: SecretValue - def headers(args=nil) + def headers(args = nil) if args @_message.headers(args) else @@ -667,7 +660,7 @@ module ActionMailer # format.html # end # - def mail(headers={}, &block) + def mail(headers = {}, &block) @_mail_was_called = true m = @_message diff --git a/actionmailer/lib/action_mailer/collector.rb b/actionmailer/lib/action_mailer/collector.rb index cbb2778fae..e8883a8235 100644 --- a/actionmailer/lib/action_mailer/collector.rb +++ b/actionmailer/lib/action_mailer/collector.rb @@ -20,7 +20,7 @@ module ActionMailer end alias :all :any - def custom(mime, options={}) + def custom(mime, options = {}) options.reverse_merge!(content_type: mime.to_s) @context.formats = [mime.to_sym] options[:body] = block_given? ? yield : @default_render.call diff --git a/actionmailer/lib/action_mailer/queued_message.rb b/actionmailer/lib/action_mailer/queued_message.rb deleted file mode 100644 index 8d200617c4..0000000000 --- a/actionmailer/lib/action_mailer/queued_message.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'delegate' - -module ActionMailer - class QueuedMessage < ::Delegator - attr_reader :queue - - def initialize(queue, mailer_class, method_name, *args) - @queue = queue - @job = DeliveryJob.new(mailer_class, method_name, args) - end - - def __getobj__ - @job.message - end - - # Queues the message for delivery. - def deliver - tap { @queue.push @job } - end - - class DeliveryJob - def initialize(mailer_class, method_name, args) - @mailer_class = mailer_class - @method_name = method_name - @args = args - end - - def message - @message ||= @mailer_class.send(:new, @method_name, *@args).message - end - - def run - message.deliver - end - end - end -end diff --git a/actionmailer/lib/action_mailer/railtie.rb b/actionmailer/lib/action_mailer/railtie.rb index 59dc26841f..7677ff3a7c 100644 --- a/actionmailer/lib/action_mailer/railtie.rb +++ b/actionmailer/lib/action_mailer/railtie.rb @@ -19,8 +19,6 @@ 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_host ||= app.config.asset_host options.relative_url_root ||= app.config.relative_url_root diff --git a/actionmailer/lib/action_mailer/test_case.rb b/actionmailer/lib/action_mailer/test_case.rb index 80f323873d..207f949fe2 100644 --- a/actionmailer/lib/action_mailer/test_case.rb +++ b/actionmailer/lib/action_mailer/test_case.rb @@ -10,13 +10,6 @@ module ActionMailer end class TestCase < ActiveSupport::TestCase - - # Use AM::TestCase for the base class when describing a mailer - register_spec_type(self) do |desc| - Class === desc && desc < ActionMailer::Base - end - register_spec_type(/Mailer( ?Test)?\z/i, self) - module Behavior extend ActiveSupport::Concern diff --git a/actionmailer/lib/action_mailer/test_helper.rb b/actionmailer/lib/action_mailer/test_helper.rb index 3ab37d8142..6452bf616c 100644 --- a/actionmailer/lib/action_mailer/test_helper.rb +++ b/actionmailer/lib/action_mailer/test_helper.rb @@ -4,9 +4,9 @@ module ActionMailer # # def test_emails # assert_emails 0 - # ContactMailer.deliver_contact + # ContactMailer.welcome.deliver # assert_emails 1 - # ContactMailer.deliver_contact + # ContactMailer.welcome.deliver # assert_emails 2 # end # @@ -15,12 +15,12 @@ module ActionMailer # # def test_emails_again # assert_emails 1 do - # ContactMailer.deliver_contact + # ContactMailer.welcome.deliver # end # # assert_emails 2 do - # ContactMailer.deliver_contact - # ContactMailer.deliver_contact + # ContactMailer.welcome.deliver + # ContactMailer.welcome.deliver # end # end def assert_emails(number) @@ -38,7 +38,7 @@ module ActionMailer # # def test_emails # assert_no_emails - # ContactMailer.deliver_contact + # ContactMailer.welcome.deliver # assert_emails 1 # end # diff --git a/actionmailer/lib/rails/generators/mailer/USAGE b/actionmailer/lib/rails/generators/mailer/USAGE index 7470289fd3..323bb8a87f 100644 --- a/actionmailer/lib/rails/generators/mailer/USAGE +++ b/actionmailer/lib/rails/generators/mailer/USAGE @@ -10,9 +10,8 @@ Example: ======== rails generate mailer Notifications signup forgot_password invoice - creates a Notifications mailer class, views, test, and fixtures: + creates a Notifications mailer class, views, and test: Mailer: app/mailers/notifications.rb - Views: app/views/notifications/signup.erb [...] + Views: app/views/notifications/signup.text.erb [...] Test: test/mailers/notifications_test.rb - Fixtures: test/fixtures/notifications/signup [...] diff --git a/actionmailer/test/abstract_unit.rb b/actionmailer/test/abstract_unit.rb index 4b38d4bd31..15729bafba 100644 --- a/actionmailer/test/abstract_unit.rb +++ b/actionmailer/test/abstract_unit.rb @@ -8,10 +8,9 @@ silence_warnings do Encoding.default_external = "UTF-8" end -require 'minitest/autorun' +require 'active_support/testing/autorun' require 'action_mailer' require 'action_mailer/test_case' -require 'active_support/queueing' silence_warnings do # These external dependencies have warnings :/ diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index 170923673b..b06c465380 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -3,13 +3,11 @@ require 'abstract_unit' require 'set' require 'action_dispatch' -require 'active_support/queueing' require 'active_support/time' require 'mailers/base_mailer' require 'mailers/proc_mailer' require 'mailers/asset_mailer' -require 'mailers/async_mailer' class BaseTest < ActiveSupport::TestCase def teardown @@ -422,17 +420,6 @@ class BaseTest < ActiveSupport::TestCase assert_equal(1, BaseMailer.deliveries.length) end - test "delivering message asynchronously" do - AsyncMailer.delivery_method = :test - AsyncMailer.deliveries.clear - - AsyncMailer.welcome.deliver - assert_equal 0, AsyncMailer.deliveries.length - - AsyncMailer.queue.drain - assert_equal 1, AsyncMailer.deliveries.length - end - test "calling deliver, ActionMailer should yield back to mail to let it call :do_delivery on itself" do mail = Mail::Message.new mail.expects(:do_delivery).once diff --git a/actionmailer/test/mailers/async_mailer.rb b/actionmailer/test/mailers/async_mailer.rb deleted file mode 100644 index c21a464f38..0000000000 --- a/actionmailer/test/mailers/async_mailer.rb +++ /dev/null @@ -1,3 +0,0 @@ -class AsyncMailer < BaseMailer - self.queue = ActiveSupport::TestQueue.new -end diff --git a/actionmailer/test/spec_type_test.rb b/actionmailer/test/spec_type_test.rb deleted file mode 100644 index 90db59c2d2..0000000000 --- a/actionmailer/test/spec_type_test.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'abstract_unit' - -class NotificationMailer < ActionMailer::Base; end -class Notifications < ActionMailer::Base; end - -class SpecTypeTest < ActiveSupport::TestCase - def assert_mailer actual - assert_equal ActionMailer::TestCase, actual - end - - def refute_mailer actual - refute_equal ActionMailer::TestCase, actual - end - - def test_spec_type_resolves_for_class_constants - assert_mailer MiniTest::Spec.spec_type(NotificationMailer) - assert_mailer MiniTest::Spec.spec_type(Notifications) - end - - def test_spec_type_resolves_for_matching_strings - assert_mailer MiniTest::Spec.spec_type("WidgetMailer") - assert_mailer MiniTest::Spec.spec_type("WidgetMailerTest") - assert_mailer MiniTest::Spec.spec_type("Widget Mailer Test") - # And is not case sensitive - assert_mailer MiniTest::Spec.spec_type("widgetmailer") - assert_mailer MiniTest::Spec.spec_type("widgetmailertest") - assert_mailer MiniTest::Spec.spec_type("widget mailer test") - end - - def test_spec_type_wont_match_non_space_characters - refute_mailer MiniTest::Spec.spec_type("Widget Mailer\tTest") - refute_mailer MiniTest::Spec.spec_type("Widget Mailer\rTest") - refute_mailer MiniTest::Spec.spec_type("Widget Mailer\nTest") - refute_mailer MiniTest::Spec.spec_type("Widget Mailer\fTest") - refute_mailer MiniTest::Spec.spec_type("Widget MailerXTest") - end -end diff --git a/actionmailer/test/test_test.rb b/actionmailer/test/test_test.rb index 139eb53359..86fd37bea6 100644 --- a/actionmailer/test/test_test.rb +++ b/actionmailer/test/test_test.rb @@ -26,147 +26,3 @@ class CrazyStringNameMailerTest < ActionMailer::TestCase assert_equal TestTestMailer, self.class.mailer_class end end - -describe TestTestMailer do - it "gets the mailer from the test name" do - assert_equal TestTestMailer, self.class.mailer_class - end -end - -describe TestTestMailer, :action do - it "gets the mailer from the test name" do - assert_equal TestTestMailer, self.class.mailer_class - end -end - -describe TestTestMailer do - describe "nested" do - it "gets the mailer from the test name" do - assert_equal TestTestMailer, self.class.mailer_class - end - end -end - -describe TestTestMailer, :action do - describe "nested" do - it "gets the mailer from the test name" do - assert_equal TestTestMailer, self.class.mailer_class - end - end -end - -describe "TestTestMailer" do - it "gets the mailer from the test name" do - assert_equal TestTestMailer, self.class.mailer_class - end -end - -describe "TestTestMailerTest" do - it "gets the mailer from the test name" do - assert_equal TestTestMailer, self.class.mailer_class - end -end - -describe "TestTestMailer" do - describe "nested" do - it "gets the mailer from the test name" do - assert_equal TestTestMailer, self.class.mailer_class - end - end -end - -describe "TestTestMailerTest" do - describe "nested" do - it "gets the mailer from the test name" do - assert_equal TestTestMailer, self.class.mailer_class - end - end -end - -describe "AnotherCrazySymbolNameMailerTest" do - tests :test_test_mailer - - it "gets the mailer after setting it with a symbol" do - assert_equal TestTestMailer, self.class.mailer_class - end -end - -describe "AnotherCrazyStringNameMailerTest" do - tests 'test_test_mailer' - - it "gets the mailer after setting it with a string" do - assert_equal TestTestMailer, self.class.mailer_class - end -end - -describe "Another Crazy Name Mailer Test" do - tests TestTestMailer - - it "gets the mailer after setting it manually" do - assert_equal TestTestMailer, self.class.mailer_class - end -end - -describe "Another Crazy Symbol Name Mailer Test" do - tests :test_test_mailer - - it "gets the mailer after setting it with a symbol" do - assert_equal TestTestMailer, self.class.mailer_class - end -end - -describe "Another Crazy String Name Mailer Test" do - tests 'test_test_mailer' - - it "gets the mailer after setting it with a string" do - assert_equal TestTestMailer, self.class.mailer_class - end -end - -describe "AnotherCrazySymbolNameMailerTest" do - tests :test_test_mailer - - describe "nested" do - it "gets the mailer after setting it with a symbol" do - assert_equal TestTestMailer, self.class.mailer_class - end - end -end - -describe "AnotherCrazyStringNameMailerTest" do - tests 'test_test_mailer' - - describe "nested" do - it "gets the mailer after setting it with a string" do - assert_equal TestTestMailer, self.class.mailer_class - end - end -end - -describe "Another Crazy Name Mailer Test" do - tests TestTestMailer - - describe "nested" do - it "gets the mailer after setting it manually" do - assert_equal TestTestMailer, self.class.mailer_class - end - end -end - -describe "Another Crazy Symbol Name Mailer Test" do - tests :test_test_mailer - - describe "nested" do - it "gets the mailer after setting it with a symbol" do - assert_equal TestTestMailer, self.class.mailer_class - end - end -end - -describe "Another Crazy String Name Mailer Test" do - tests 'test_test_mailer' - - it "gets the mailer after setting it with a string" do - assert_equal TestTestMailer, self.class.mailer_class - end -end |