On Saturday, February 1, 2014 10:36:42 PM UTC-8, Sean West wrote: > > I'm utilizing the after_commit hook to run some background jobs and it is > working great. I am running into problems with the tests though as each > test is transactional and triggering a rollback, so after_commit is never > called. > > I am using Test::Unit for my tests with the run method overridden as > suggested by the 'Testing with Sequel' document: > > http://sequel.jeremyevans.net/rdoc/files/doc/testing_rdoc.html > > class SequelTestCase < Test::Unit::TestCase > def run(*args, &block) > result = nil > Sequel::Model.db.transaction(:rollback=>:always){result = super} > result > endend > > > What is the best way to ensure that the after_commit hooks are called when > running the tests? I imagine others have run into this problem before as > well, however I can't find any clues out there for Sequel. Is there > something simple I'm missing? > > I'm currently hacking my way around it by simply calling the after_commit > method directly from my test. >
If you want to test after_commit/after_rollback code, you need to disable transactions for that test method (or test suite). Thanks, Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/groups/opt_out.
