diff options
author | José Valim and Mikel Lindsaar <pair@programming.com> | 2010-01-24 12:30:13 +1100 |
---|---|---|
committer | José Valim and Mikel Lindsaar <pair@programming.com> | 2010-01-24 12:30:13 +1100 |
commit | afc758297c553de467b0c434330cb703d62795f1 (patch) | |
tree | d81ab5f36a62449eb6eb4c70c2f6ecf3d63c2759 /actionmailer | |
parent | 258ca148004eaa63740ab2186338b3ac872b8187 (diff) | |
download | rails-afc758297c553de467b0c434330cb703d62795f1.tar.gz rails-afc758297c553de467b0c434330cb703d62795f1.tar.bz2 rails-afc758297c553de467b0c434330cb703d62795f1.zip |
Moving AS::Notifications call to one location in base
Diffstat (limited to 'actionmailer')
-rw-r--r-- | actionmailer/lib/action_mailer/deprecated_api.rb | 16 | ||||
-rw-r--r-- | actionmailer/test/base_test.rb | 7 |
2 files changed, 9 insertions, 14 deletions
diff --git a/actionmailer/lib/action_mailer/deprecated_api.rb b/actionmailer/lib/action_mailer/deprecated_api.rb index a9ebd70f86..a2fa481d0e 100644 --- a/actionmailer/lib/action_mailer/deprecated_api.rb +++ b/actionmailer/lib/action_mailer/deprecated_api.rb @@ -83,19 +83,17 @@ module ActionMailer # email.set_some_obscure_header "frobnicate" # MyMailer.deliver(email) def deliver(mail) + return if @mail_was_called raise "no mail object available for delivery!" unless mail - ActiveSupport::Notifications.instrument("action_mailer.deliver", :mailer => self.name) do |payload| - self.set_payload_for_mail(payload, mail) + mail.register_for_delivery_notification(self) - mail.delivery_method delivery_methods[delivery_method], - delivery_settings[delivery_method] - - mail.raise_delivery_errors = raise_delivery_errors - mail.perform_deliveries = perform_deliveries - mail.deliver - end + mail.delivery_method delivery_methods[delivery_method], + delivery_settings[delivery_method] + mail.raise_delivery_errors = raise_delivery_errors + mail.perform_deliveries = perform_deliveries + mail.deliver mail end diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index 43a9fb29bb..0b650e9a28 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -325,15 +325,12 @@ class BaseTest < ActiveSupport::TestCase end test "ActionMailer should be told when Mail gets delivered" do + BaseMailer.deliveries.clear BaseMailer.expects(:delivered_email).once email = BaseMailer.deliver_welcome + assert_equal(1, BaseMailer.deliveries.length) end - # test "ActionMailer should be told when Mail gets delivered using new API" do - # BaseMailer.expects(:delivered_email).once - # email = BaseMailer.welcome.deliver - # end - protected # Execute the block setting the given values and restoring old values after |