Why after_commit not running even with use_transactional_fixtures = false

后端 未结 5 2350
悲哀的现实
悲哀的现实 2021-02-19 03:03

Transactional fixtures in rspec prevent after_commit from being called, but even when I disable them with

RSpec.configure do |config|
  config.use_transactional_         


        
5条回答
  •  北荒
    北荒 (楼主)
    2021-02-19 03:53

    In my case I resolved such problem with database_cleaner's settings placed below:

    config.use_transactional_fixtures = false
    
    config.before(:suite) do
      DatabaseCleaner.strategy = :deletion
      DatabaseCleaner.clean_with(:truncation)
    end
    
    config.before(:each) do
      DatabaseCleaner.start
    end
    
    config.after(:each) do
      DatabaseCleaner.clean
    end
    

    Thanks to Testing after_commit/after_transaction with Rspec

提交回复
热议问题