ActiveRecord Rollback does not work in Rails test

后端 未结 2 862
眼角桃花
眼角桃花 2020-12-20 05:18

Throwing ActiveRecord::Rollback works, but not in tests.

I\'ve had this problem before, am now having it again, and for some reason can\'t find any record of someone

相关标签:
2条回答
  • 2020-12-20 05:37

    Actually the method to call is as follows:

    class RollbackTest < ActiveSupport::TestCase
      self.use_transactional_fixtures = false
    

    not self.use_transaction_fixtures (note the missing 'al')

    0 讨论(0)
  • 2020-12-20 05:42

    You should turn off transactions in your test case:

    class RollbackTest < ActiveSupport::TestCase
      self.use_transactional_fixtures = false
    

    [edit: as per @Conrad's comment it should be transactionAL]

    0 讨论(0)
提交回复
热议问题