Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 6 & deliver_later doesn't affect ActionMailer::Base.deliveries

After upgrading to Rails 6 I am noticing that default mailer's .deliver_later is not working the same as in Rails 5.

Configuration:

config.active_job.queue_adapter = :inline

When running Mailer.register_email(...).deliver_later - nothing is stored in ActionMailer::Base.deliveries. This array gets filled if I run perform_enqueued_jobs - it seams like queue_adapter = :inline doesn't work the way I expect it to work.

If I run Mailer.send(...).deliver_now then ActionMailer::Base.deliveries has proper value in it.

Any idea why this is happening and how to solve this?

like image 647
knagode Avatar asked Sep 03 '19 17:09

knagode


People also ask

What are the features of rails 6?

Rails 6 release date and features. 1 1) Action Mailbox. In Rails 5, we were using ActionMailer to manage mails in the application. Action Mailbox is extracted from Basecamp, which gives ... 2 2) Action Text. 3 3) Parallel Testing. 4 4) Action Cable Testing. 5 5) Webpack.

What is the latest version of rails 6 RC2?

Rails 6 latest version rc2 has now released on July 22, 2019. This may be the best-exercised RC (release candidate) in Rails history. Because Rails has been released with three beta versions so far. Companies like Basecamp, Shopify and Github already using rc1 in the production.

How to upgrade rails 5 to rails 6?

First, you need to consider your application rails version is 5.2 and you need to upgrade to rails version 6. And your current app rails version has latest patch version before moving to the next major/minor version. Rails 6 require Ruby version 2.5 or greater. You need to check all your gems from Gemfile are compatible with Rails 6 gem.

What's new in Ruby on rails 6?

Since Ruby on Rails has been around for years, few people expect revolutionary changes, but its sixth incarnation brings a lot to the table. Some features rolled out in Rails 6 seem like minor improvements, while others have the potential to save a lot of development time, improve security, robustness, and so on.


1 Answers

I had same problem in my tests. A search on the Internet yielded nothing, so I started experimenting.

I tried wrapping the call method of sending mail in

assert_emails 1 do
  Mailer.register_email(...).deliver_later
end

After that, ActionMailer::Base.deliveries populated correctly.

like image 170
RomanOks Avatar answered Oct 08 '22 09:10

RomanOks