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

Add a section about job testing #17476

Merged
merged 1 commit into from Nov 8, 2014
Merged

Add a section about job testing #17476

merged 1 commit into from Nov 8, 2014

Conversation

robin850
Copy link
Member

@robin850 robin850 commented Nov 1, 2014

Hello,

This pull request is just a follow up to #16921 addressing the different comments. This part makes the distinction between normal job testing and asserting that a job get enqueued/performed inside other components like models.

Also it makes the assumption that ActiveJob::TestHelper's methods are available directly from ActiveSupport::TestCase as it should normally be the case (c.f. #17475).

Cross-refs #16576.

Have a nice day.

------------

Since your custom jobs can be queued at different levels inside your application
(e.g. inside your models or controllers), you'll need to test both jobs themselves
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "different levels inside your application" is enough, we don't need the examples.

@robin850
Copy link
Member Author

robin850 commented Nov 2, 2014

@sgrif : Updated ; thanks for the review ! :-)

| -------------------------------------- | ------- |
| `assert_enqueued_jobs(number)` | Asserts that the number of enqueued jobs matches the given number. |
| `assert_performed_jobs(number)` | Asserts that the number of performed jobs matches the given number. |
| `assert_no_enqueued_jobs { ... }` | Asserts that no jobs have been enqueued within the block. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with assert_no_performed_jobs and because passing a block is optional, should we rewrite the purpose as Asserts that no jobs have been enqueued?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, good catch ! 👍

* Cover lower level job testing (assertions about the execution of the
  job itself).
* Add a table with the custom assertions provided by Active Job's
  `TestHelper` module.
* Add an example testing job queuing inside a model
@chancancode
Copy link
Member

@robin850 since you are on the issues team, I'll assign this back to you. You can solicit feedback directly from those who might be able to help you and merge this when it's ready

robin850 added a commit that referenced this pull request Nov 8, 2014
Add a section about job testing [ci skip]
@robin850 robin850 merged commit f8f02f4 into rails:master Nov 8, 2014
@robin850 robin850 deleted the job-testing branch November 8, 2014 11:37
@robin850
Copy link
Member Author

robin850 commented Nov 8, 2014

Thanks you very much everyone ! ❤️

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

Successfully merging this pull request may close these issues.

None yet

5 participants