| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
| |
The constant `PERMITTED_TYPES` is only used by the private method
`serialize_argument` and it already has the `# :nodoc:` annotation as
the other constants in the class.
Complements e899e22
|
|
|
|
|
| |
This commit adds missing types to the supported types list, which
was extended in #30941
|
|
|
|
| |
https://github.com/rails/rails/pull/30941/files#diff-fc90ec41ef75be8b2259526fe1a8b663L53
|
|
|
|
|
| |
Restore HashWithIndifferentAccess support to
ActiveJob::Arguments.deserialize.
|
|\
| |
| | |
Improve `enqueue_retry.active_job` message
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Since #33751 was added `enqueue_retry.active_job` instrumentation to
the `retry_on` method, then #33897 moved the instrumentation to `retry_job`
method in order to ensure that this method publish `enqueue_retry.active_job`
notification too.
See related discussion https://github.com/rails/rails/pull/33751#discussion_r214140008
Since `enqueue_retry.active_job` moved to `retry_job`, there is no guarantee
that payload of `enqueue_retry.active_job` would have `:error`.
See test `LoggingTest#test_enqueue_retry_logging_on_retry_job` as
example of that case.
Related to https://github.com/rails/rails/pull/33897#discussion_r219707024
I think we can improve notification of `enqueue_retry.active_job`:
- If there is no `event.payload[:error]`, then publish like
"Retrying RescueJob in 3 seconds." only.
- If `event.payload[:wait]` is `nil`, then publish
"Retrying RescueJob in 0 seconds." instead of "Retrying RescueJob in nil seconds."
- If there is `event.payload[:error]`, then publish
"Retrying RescueJob in 3 seconds, due to a DefaultsError.".
- Change the type of the message from `error` to `info.`
Also, this commit removes part of messages - "The original exception was #{ex.cause.inspect}."
of `enqueue_retry.active_job`, `retry_stopped.active_job`, and `discard.active_job` since I
haven't found it useful. Please let me know whether you agree with that?
|
|\ \
| | |
| | | |
Include deserialized arguments in jobs returned by AJ test helpers
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
`assert_enqueued_with` and `assert_performed_with` return a instantiated
instance of the matching job for further assertion (#21010).
Before this commit the `arguments` method on the returned instance
returns a serialized version of the arguments.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
I found a few sentences that should be updated as well.
See https://github.com/rails/rails/pull/33571#discussion_r209435886
Follow up #33571
|
| | | |
|
|/ /
| |
| |
| |
| | |
Using `included` to define `attr_acessor` and `attr_writer` is causing
these methods to not show up in the documentation.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Since Rails 6.0 will support Ruby 2.4.1 or higher
`# frozen_string_literal: true` magic comment is enough to make string object frozen.
This magic comment is enabled by `Style/FrozenStringLiteralComment` cop.
* Exclude these files not to auto correct false positive `Regexp#freeze`
- 'actionpack/lib/action_dispatch/journey/router/utils.rb'
- 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb'
It has been fixed by https://github.com/rubocop-hq/rubocop/pull/6333
Once the newer version of RuboCop released and available at Code Climate these exclude entries should be removed.
* Replace `String#freeze` with `String#-@` manually if explicit frozen string objects are required
- 'actionpack/test/controller/test_case_test.rb'
- 'activemodel/test/cases/type/string_test.rb'
- 'activesupport/lib/active_support/core_ext/string/strip.rb'
- 'activesupport/test/core_ext/string_ext_test.rb'
- 'railties/test/generators/actions_test.rb'
|
| |
| |
| |
| |
| |
| |
| | |
* Documentation clarity in ActiveJob::TestHelper [ci skip]
* Documentation for options
[Mohit Natoo + Rafael Mendonça França]
|
|\ \
| | |
| | |
| | |
| | | |
Documentation for queue_adapter_name method in ActiveJob::QueueAdapter
[ci skip]
|
| | | |
|
| |/
|/|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
- When calling `assert_performed_with`/`assert_enqueued_with`, the
+args+ needs to match exactly what the job get passed.
Some jobs can have lot of arguments, or even a simple hash argument
has many key. This is not convenient to test as most tests doesn't
need to check if the arguments matches perfectly.
This PR make it possible to only check if a subset of arguments were
passed to the job.
|
| |
| |
| |
| | |
Similar to Action View's and Action Controller's instrument helpers.
|
| | |
|
| |
| |
| |
| | |
The test helpers now treat `{ a: 1, b: 2 }` and `{ b: 2, a: 1 }` as equals
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Also this commit removes `:wait` from payload of
`retry_stopped.active_job`.
Related to https://github.com/rails/rails/pull/33751#discussion_r214140008
Follow up #33751
/cc @kaspth, @rafaelfranca
|
| |
| |
| |
| | |
Fix typo `Instrinsic` -> `Intrinsic`
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
As @dhh brings up, the point of `ActionDispatch::IntegrationTest` is to
allow users to test the integration of all the pieces called by a
controller. Asserting about the emails and jobs queued is part of that
task.
This commit includes the `ActionMailer::TestHelper` and
`ActiveJob::TestHelper` modules when the ActionMailer and ActiveJob
railties are initialized respectively.
|
|\ \
| | |
| | | |
ActiveJob Backburner adapter: fix priority
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
The priority wasn't being passed from ActiveJob to Backburner, despite
priority being supported. This also brings it inline with the docs,
which mark Backburner as supporting priorities in the "Backend Features"
table: https://api.rubyonrails.org/classes/ActiveJob/QueueAdapters.html
|
|/ / |
|
|\ \
| | |
| | | |
Add hooks to ActiveJob around retries and discards
|
| | | |
|
| | | |
|
| | | |
|
|/ / |
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Example:
```
def test_assert_performed_with
MyJob.perform_later(1,2,3)
perform_enqueued_jobs
assert_performed_with(job: MyJob, args: [1,2,3], queue: 'high')
end
```
Follow up #33626.
|
| |
| |
| |
| |
| | |
Execution of `assert_performed_jobs`, and `assert_no_performed_jobs`
without a block should respect passed `:except`, `:only`, and `:queue` options.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
If the `:queue` option is specified, then only the job(s) enqueued to a specific
queue will not be performed.
Example:
```
def test_assert_no_performed_jobs_with_queue_option
assert_no_performed_jobs queue: :some_queue do
HelloJob.set(queue: :other_queue).perform_later("jeremy")
end
end
```
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
If the `:queue` option is specified, then only the job(s) enqueued to a specific
queue will be performed.
Example:
```
def test_assert_performed_jobs_with_queue_option
assert_performed_jobs 1, queue: :some_queue do
HelloJob.set(queue: :some_queue).perform_later("jeremy")
HelloJob.set(queue: :other_queue).perform_later("bogdan")
end
end
```
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Set
````
queue_adapter.perform_enqueued_jobs = true
queue_adapter.perform_enqueued_at_jobs = true
queue_adapter.filter = only
queue_adapter.reject = except
queue_adapter.queue = queue
```
if block given.
Execution of `flush_enqueued_jobs` doesn't require that.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
If the `:queue` option is specified, then only the job(s) enqueued to
a specific queue will be performed.
Example:
```
def test_perform_enqueued_jobs_with_queue
perform_enqueued_jobs queue: :some_queue do
MyJob.set(queue: :some_queue).perform_later(1, 2, 3) # will be performed
HelloJob.set(queue: :other_queue).perform_later(1, 2, 3) # will not be performed
end
assert_performed_jobs 1
end
```
Follow up #33265
[bogdanvlviv & Jeremy Daer]
|
| |
| |
| |
| |
| |
| |
| |
| | |
Currently, the execution count increments after deserializes arguments.
Therefore, if an error occurs with deserialize, it retries indefinitely.
In order to prevent this, the count is moved before deserialize.
Fixes #33344.
|
| |
| |
| |
| | |
Follow up #33626
|
| |
| |
| |
| | |
Performs all of the jobs that have been enqueued up to this point in the test.
|
|/ |
|
|
|
|
|
| |
http links will be redirected to the https version, but still better to
just directly link to the https version.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
It breaks Active Job when run in isolation. E.g. bin/test test/cases/logging_test.rb:
https://travis-ci.org/rails/rails/jobs/398779028
Consider Rafaels suggestion of reviewing the eager loading instead:
https://github.com/rails/rails/pull/33234#issuecomment-401027419
This reverts commit cb0fdaacb277bd0595bfd73178329922aa24477e, reversing
changes made to a0a1abb3c7942084111d87ae95837a83bcc794f6.
|
|
|
|
|
|
|
|
|
|
|
| |
It can be asserted that no jobs are enqueued to a specific queue:
```ruby
def test_no_logging
assert_no_enqueued_jobs queue: 'default' do
LoggingJob.set(queue: :some_queue).perform_later
end
end
```
|
|
|
|
|
|
|
|
|
|
|
| |
Rename `in_block_job` to `enqueued_job` since this variable can refer not only
to jobs that were created in the block.
See #33258.
Return back accidentally removed test to activejob/test/cases/test_helper_test.rb
See #33258.
Fix name of tests.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Example of `assert_enqueued_with` with no block
```ruby
def test_assert_enqueued_with
MyJob.perform_later(1,2,3)
assert_enqueued_with(job: MyJob, args: [1,2,3], queue: 'low')
MyJob.set(wait_until: Date.tomorrow.noon).perform_later
assert_enqueued_with(job: MyJob, at: Date.tomorrow.noon)
end
```
Example of `assert_enqueued_email_with` with no block:
```ruby
def test_email
ContactMailer.welcome.deliver_later
assert_enqueued_email_with ContactMailer, :welcome
end
def test_email_with_arguments
ContactMailer.welcome("Hello", "Goodbye").deliver_later
assert_enqueued_email_with ContactMailer, :welcome, args: ["Hello", "Goodbye"]
end
```
Related to #33243
|