Craig Miles
Craig Miles

Reputation: 495

Rails 7.2 issue testing activejob with sidekiq

I have a Rails 7.1 application that uses Sidekiq with ActiveJob for background jobs.

I have developed a suite of feature tests using Cucumber/Capybara/Selenium.

When the application was first developed it seemed necessary to use database_cleaner and connection_pool gems to ensure that a test case ran within a transaction that could be cleaned up using the transaction strategy to return the database to the initial state after each test case, also bearing in mind that the test scenario and the background jobs were running under different processes.

I am not 100% certain that this is still required under Rails 7.1 and cannot now be handled some other way, but still.

Trying to upgrade to Rails 7.2, I note that new ActiveJob behavior exists around the handling of jobs within transactions.

I am now seeing that the teardown of a test with sidekiq is now not successful under Rails 7.2 and is causing the subsequent test to fail.

I am assuming that this as a result of the changed behavior in Rails 7.2 but don't know how best to address?

Do I now need to pivot to a truncation cleanup strategy after each test? Any suggestions?

Upvotes: 0

Views: 203

Answers (0)

Related Questions