Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to unit test send_later effectively #21

Open
noctivityinc opened this issue Feb 18, 2010 · 1 comment
Open

No way to unit test send_later effectively #21

noctivityinc opened this issue Feb 18, 2010 · 1 comment

Comments

@noctivityinc
Copy link

I am trying to unit test DJ with some emails that are being set to send_later. While I can check the database for the record, it seems like it would make more sense if I could:

1 - Check that DJ has it
2 - Simulate a run
3 - Check to make sure it ran as expected.

Any thoughts?

@ctaintor
Copy link

Yup. You should be able to do the following in a unit test:

  1. Verify there are no delayed jobs already in the db:
    assert_equal 0, Delayed::Job.count
  2. Make a call that will result in the job being enqueued
  3. Verify that DJ has it
    assert_equal 1, Delayed::Job.count
  4. Simulate a run
    Delayed::Worker.new.work_off
  5. Check that it ran as expected
    assert_equal 0, Delayed::Job.count
    and then any assertions that you need to do to check that DJ actually worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants