Commit Graph

133 Commits

Author SHA1 Message Date
Rafael Mendonça França
5e6e505083
Preparing for 6.0.0.beta2 release 2019-02-25 17:45:04 -05:00
Rafael Mendonça França
5a0230c67f
Preparing for 6.0.0.beta1 release 2019-01-18 15:42:12 -05:00
George Claghorn
e3f832a743 Deprecate ActionMailer::Base.receive in favor of Action Mailbox 2018-12-27 21:17:58 -05:00
Kasper Timm Hansen
1b7c3222e8
Require Ruby 2.5 for Rails 6.
Generally followed the pattern for https://github.com/rails/rails/pull/32034

* Removes needless CI configs for 2.4
* Targets 2.5 in rubocop
* Updates existing CHANGELOG entries for fewer merge conflicts
* Removes Hash#slice extension as that's inlined on Ruby 2.5.
* Removes the need for send on define_method in MethodCallAssertions.
2018-12-19 21:47:50 +01:00
Gannon McGibbon
f5050d998d Add MailDeliveryJob for unified mail delivery
Add `MailDeliveryJob` for delivering both regular and parameterized mail.
Deprecate using `DeliveryJob` and `Parameterized::DeliveryJob`.
2018-12-04 11:00:34 -05:00
Gannon McGibbon
60339da5bc Deliver parameterized mail with DeliveryJob
Deliver parameterized mail with `ActionMailer::DeliveryJob`
and remove `ActionMailer::Parameterized::DeliveryJob`.
2018-11-22 18:37:53 -05:00
Edouard CHIN
e139a3ce13 Fix ActionMailer assertion not working for mail defining delivery_job:
- If a Mail defines a custom delivery_job, all ActionMailer assertion
  helper (assert_emails, assert_enqueued_emails ...) wouldn't work.

  ```ruby
    MyMailer < ApplicationMailer
      self.delivery_job = MyJob
    end

    # This assertion will fail
    assert_emails(1) do
      MyMailer.my_mail.deliver_later
    end

  This PR leverage the new ActiveJob feature that accepts Procs for the
  `only` keyword and check if the delivery job is one of ActionMailer
   registered ones.
2018-11-21 23:17:04 +01:00
Rafael Mendonça França
72062c8c9d Merge pull request #22534 from evopark/master
ActionMailer: support overriding template name in multipart
2018-11-19 19:23:44 -05:00
Luke Pearce
c90c6c1344 Parameterized mailers can configure delivery job
Setting parameterized_delivery_job on a mailer class will cause Parameterized::MessageDelivery to use
the specified job instead of ActionMailer::Parameterized::DeliveryJob:

    class MyMailer < ApplicationMailer
      self.parameterized_delivery_job = MyCustomDeliveryJob
      ...
    end
2018-10-05 17:02:40 +01:00
bogdanvlviv
5a212939c2
Add changelog entries for #33849 [ci skip]
Since these changes related to the public API, I think we should add
changelog entries.

Related to #33838, #33849
2018-09-13 16:58:56 +03:00
Yoshiyuki Kinjo
576209b45b Add perform_deliveries to a payload of deliver.action_mailer notification. 2018-09-09 20:17:36 +09:00
Yoshiyuki Kinjo
383b8bc8e2 Skip delivery notification when perform_deliveries is false. 2018-09-08 17:29:28 +09:00
bogdanvlviv
4382fcbc22
Allow call assert_enqueued_with and assert_enqueued_email_with with no block
Example of `assert_enqueued_with` with no block
```ruby
def test_assert_enqueued_with
  MyJob.perform_later(1,2,3)
  assert_enqueued_with(job: MyJob, args: [1,2,3], queue: 'low')

  MyJob.set(wait_until: Date.tomorrow.noon).perform_later
  assert_enqueued_with(job: MyJob, at: Date.tomorrow.noon)
end
```

Example of `assert_enqueued_email_with` with no block:
```ruby
def test_email
  ContactMailer.welcome.deliver_later
  assert_enqueued_email_with ContactMailer, :welcome
end

def test_email_with_arguments
  ContactMailer.welcome("Hello", "Goodbye").deliver_later
  assert_enqueued_email_with ContactMailer, :welcome, args: ["Hello", "Goodbye"]
end
```

Related to #33243
2018-06-29 15:37:02 +03:00
Kota Miyake
b74edd37c5 ActionMailer::Base can unregister observer(s) and interceptor(s). (#32207)
* ActionMailer::Base can unregister observer(s) and interceptor(s).

One or multiple mail observers can be unregistered using
`ActionMailer::Base.unregister_observers` or
`ActionMailer::Base.unregister_observer`.

One or multiple mail interceptors can be unregistered using
`ActionMailer::Base.unregister_interceptors` or
`ActionMailer::Base.unregister_interceptor`.

For preview interceptors, it's possible to use
`ActionMailer::Base.unregister_preview_interceptors` or
`ActionMailer::Base.unregister_preview_interceptor`.

* Ensure to be reset registered observer(s) and interceptor(s)

* Add explanation to CHANGELOG

* Add original author's name

[Kota Miyake + Rafael Mendonça França + Claudio Ortolina]
2018-05-30 17:36:24 -04:00
Samuel Cochran
4d43b05881 Eager autoload mail gem when eager load is true (#32808)
* Eager autoload mail gem when eager load is true

We had a production issue where our Sidekiq worker threads all became
deadlocked while autoloading a file within the mail gem, required via
ActionMailer, despite setting our Rails applicaiton to eager load.
`Mail.eager_autoload!` exists and works great, ActionMailer just doesn't
call it during eager loading. Adding it to the ActionMailer Railtie's
eager_load_namespaces takes care of calling `Mail.eager_autoload!`
during the `eager_load!` initializer.

* 'Mail' isn't defined yet, use before_eager_load instead

* Make sure mail is loaded

* Move eager load of Mail into ActionMailer.eager_load!

[Samuel Cochran + Rafael Mendonça França]
2018-05-23 16:50:36 -04:00
Rafael Mendonça França
f36e298ca7
Merge pull request #32231 from gmcgibbon/perform_email_jobs_in_assert_emails
Perform email jobs in #assert_emails
2018-03-13 15:18:49 -04:00
Jeremy Daer
d4eb0dc89e Rails 6 requires Ruby 2.4.1+
Skipping over 2.4.0 to sidestep the `"symbol_from_string".to_sym.dup` bug.

References #32028
2018-02-17 15:34:57 -08:00
Rafael Mendonça França
1c383df324 Start Rails 6.0 development!!!
🎉🎉🎉
2018-01-30 18:51:17 -05:00
Ryuta Kamizono
6003dafc1f Merge pull request #30391 from jbourassa/fix-actionmailer-lambda-default
Fix actionmailer lambda default
2018-01-24 06:01:25 +09:00
Rafael Mendonça França
2837d0f334
Preparing for 5.2.0.beta2 release 2017-11-28 14:41:02 -05:00
Rafael Mendonça França
cceeeb6e57
Preparing for 5.2.0.beta1 release 2017-11-27 14:50:03 -05:00
Ryuta Kamizono
fced30c373 Cleanup CHANGELOGs [ci skip]
* Add missing credit
* Add backticks
* Fix indentation
* Remove trailing spaces

And some minor tweaks.
2017-10-04 07:27:33 +09:00
Mikkel Malmberg
db6847dcb6 Add assert_enqueued_email_with to ActionMailer::TestHelper 2017-09-27 23:22:49 +02:00
Jimmy Bourassa
fbb2fc8aa7 Fix AM::Base.default proc arity breaking change
PR #29270 changed the number of arguments that gets passed to Procs
defined in ActionMail::Base.default. With this changeset, Procs can
now have 1 or 0 arguments

Also adds test coverage for AM::Base.default Proc arity.
2017-08-29 09:42:28 -04:00
Ryuta Kamizono
6e227ad345 Fix indentation [ci skip] 2017-06-15 21:44:19 +09:00
Matthew Mongeau
d9bbde09fc Allow mailers to configure their delivery job
Setting delivery_job on a mailer class will cause MessageDelivery to use
the specified job instead of ActionMailer::DeliveryJob:

    class MyMailer < ApplicationMailer
      self.delivery_job = MyCustomDeliveryJob

      ...
    end
2017-06-15 16:41:23 +09:00
Matthew Draper
6c08d480f1 Start Rails 5.2 development 2017-03-22 10:11:39 +10:30
Rafael Mendonça França
f4acdd83ff
Preparing for 5.1.0.beta1 release 2017-02-23 14:53:21 -05:00
Jon Moss
f4d2bcdd6d Add backticks around constant
[ci skip]
2017-02-21 11:45:50 -05:00
yuuji.yaginuma
53b98f1dda Add :args to process.action_mailer event 2017-02-04 11:43:24 +09:00
David Heinemeier Hansson
1cec84ad2d Offer the option to use parameterization for shared processing of headers and ivars (#27825)
Offer the option to use parameterization for shared processing of headers and ivars
2017-01-28 11:20:46 +01:00
Rafael Mendonça França
e482dce0ed
Merge pull request #27227 from MQuy/allow-custom-content-type-in-mail-body
Allow to custom content type when setting mailer body
2017-01-06 06:03:41 -05:00
MQuy
2263769c79 Add changelog for custom content type 2016-12-01 10:18:00 +08:00
Jeremy Daer
e35b98e6f5
Action Mailer: Declarative exception handling with rescue_from.
Follows the same pattern as controllers and jobs. Exceptions raised in
delivery jobs (enqueued by `#deliver_later`) are also delegated to the
mailer's rescue_from handlers, so you can handle the DeserializationError
raised by delivery jobs:

```ruby
class MyMailer < ApplicationMailer
  rescue_from ActiveJob::DeserializationError do
    …
  end
```

ActiveSupport::Rescuable polish:
* Add the `rescue_with_handler` class method so exceptions may be
  handled at the class level without requiring an instance.
* Rationalize `exception.cause` handling. If no handler matches the
  exception, fall back to the handler that matches its cause.
* Handle exceptions raised elsewhere. Pass `object: …` to execute
  the `rescue_from` handler (e.g. a method call or a block to
  instance_exec) against a different object. Defaults to `self`.
2016-05-15 18:44:16 -07:00
Rafael Mendonça França
8ecc5ab1d8 Start Rails 5.1 development 🎉 2016-05-10 03:46:56 -03:00
Rafael Mendonça França
fbdcf5221a Preparing for 5.0.0.rc1 release 2016-05-06 16:54:40 -05:00
eileencodes
f7a986012a Prep Rails 5 beta 4 2016-04-27 15:48:47 -05:00
Vipul A M
829650ebe4 Pass over AM changelog
- Fixed statement about setting `config.action_mailer.default_url_options = {protocol: 'https'}` . We are just setting the protocol key to 'https', not replacing/initializing the complete config.
- Fixed grammar in assert_emails changlog
- Added sentence separator for code ":"

[ci skip]
2016-04-10 23:45:58 +05:30
Jeremy Daer
95e06e6682 Disallow calling #deliver_later after local message modifications.
They would be lost when the delivery job is enqueued, otherwise.
Prevents a common, hard-to-find bug like:

```ruby
message = Notifier.welcome(user, foo)
message.message_id = my_generated_message_id
message.deliver_later
```

The message_id is silently lost here! *Only the mailer arguments are
passed to the delivery job.*

This raises an exception now.

Make modifications to the message within the mailer method or use a
custom Active Job to manage delivery instead of using #deliver_later.
2016-04-07 13:36:50 -07:00
arktisklada
23e4c968d2 Sendmail default arguments match Mail::SendMail
Removes `-t`
2016-04-05 14:11:37 -05:00
Prathamesh Sonpatki
5ac7bd3ec4 Pass over CHANGELOGs [ci skip] 2016-03-30 12:23:29 +05:30
eileencodes
dbfa8fdfc2 Preparing for 5.0.0.beta3 release
Adds changelog headers for beta3 release
2016-02-24 11:14:40 -05:00
Rafael Mendonça França
40be61dfda Add changelog entry for #22825 2016-02-24 00:13:50 -03:00
Yves Senn
9d37874732 reset ActionMailer::Base.deliveries in ActionDispatch::IntegrationTest.
Whenever you are sending emails in integration tests using the `:test`
delivery method you need to make sure that
`ActionMailer::Base.deliveries` is reset after every test. This piece of
boilerplate code is present in all my applications that send
emails. Let's have `ActionDispatch::IntegrationTest` reset the
deliveries automatically.
2016-02-16 11:20:59 +01:00
Sean Griffin
49f6ce63f3 Preparing for Rails 5.0.0.beta2 2016-02-01 14:37:52 -07:00
Yves Senn
c8ca57df5b release notes, extract notable changes from Action Mailer CHANGELOG.
[ci skip]
2015-12-22 13:35:34 +01:00
Genadi Samokovarov
c5b6ec7b0f No more no changes entries in the CHANGELOGs
During the `5.0.0.beta1` release, the CHANGELOGs got an entry like the
following:

```
* No changes.
```

It is kinda confusing as there are indeed changes after it. Not a
biggie, just a small pass over the CHANGELOGs.

[ci skip]
2015-12-21 11:46:38 +02:00
eileencodes
099ddfdefd Add CHANGELOG headers for Rails 5.0.0.beta1 2015-12-18 15:58:25 -05:00
Marcus Ilgner
5c54db290f
ActionMailer: support overriding template name in multipart
Implicit rendering in multipart blocks now also uses the template
name from the options hash instead of always using the action name.

So you can now write

    mail(template_name: template_name) do |format|
      format.text
      format.html
    end
2015-12-08 15:50:43 +01:00
Sean Griffin
3faf748562 Revert "Merge pull request #18446 from cloud8421/actionmailer-unregister-interceptor"
This reverts commit 65a61ab7c370d2894c11ce276725f723a5c9c111, reversing
changes made to 14314ca18302f18c3d8bb7a63e9f71ac4c2290c2.

This PR broke the build
2015-11-23 15:01:24 -07:00