-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support deferred Mailer deliver with
deliver_later
Re-opens [#4224][] By default, all `Devise::Models::Authenticatable`-initiated Action Mailer deliveries are transmitted immediately (within the request-response cycle). Transmitting emails and interacting with any third-party services over SMTP or HTTP risk service outages and other types of network-related failures. This commit adds support for deferring delivery to be done from an Action Job background worker queue through the [deliver_later][] method. ```ruby # config/initializers/devise.rb Devise.mailer_delivery_method = :deliver_later ``` [#4224]: #4224 [deliver_now]: https://edgeapi.rubyonrails.org/classes/ActionMailer/MessageDelivery.html#method-i-deliver_now [deliver_later]: https://edgeapi.rubyonrails.org/classes/ActionMailer/MessageDelivery.html#method-i-deliver_later
- Loading branch information
1 parent
ec06745
commit 4170a05
Showing
5 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,20 @@ def computed_reply_to | |
assert mail.from, "[email protected]" | ||
assert mail.reply_to, "[email protected]" | ||
end | ||
|
||
test "defaults to immediate delivery" do | ||
create_user | ||
|
||
assert_not_empty ActionMailer::Base.deliveries | ||
assert_empty ActiveJob::Base.queue_adapter.enqueued_jobs | ||
end | ||
|
||
test "supports deferred delivery with Devise.mailer_delivery_method = :deliver_later" do | ||
swap Devise, mailer_delivery_method: :deliver_later do | ||
create_user | ||
|
||
assert_empty ActionMailer::Base.deliveries | ||
assert_not_empty ActiveJob::Base.queue_adapter.enqueued_jobs | ||
end | ||
end | ||
end |