aboutsummaryrefslogtreecommitdiffstats
path: root/activejob
Commit message (Collapse)AuthorAgeFilesLines
* Support in-flight jobs stored before individual execution counters for ↵Rosa Gutierrez2019-01-053-21/+39
| | | | | | | | | | | | | | | | | | | | `retry_on` (#34731) Also, make tests and examples for individual execution counters clearer, as it wasn't entierly clear what would happen in this case: ``` retry_on CustomException, OtherException, attempts: 3 ``` The job would be retried at most 3 times in total, for both CustomException and OtherException. To have the job retry 3 times at most for each exception individually, the following retry_on declarations are necessary: ``` retry_on CustomException, attempts: 3 retry_on OtherException, attempts: 3 ```
* Bump license years for 2019Arun Agrawal2018-12-312-2/+2
|
* Enable `Style/RedundantBegin` cop to avoid newly adding redundant begin blockRyuta Kamizono2018-12-217-72/+50
| | | | | | | | | | Currently we sometimes find a redundant begin block in code review (e.g. https://github.com/rails/rails/pull/33604#discussion_r209784205). I'd like to enable `Style/RedundantBegin` cop to avoid that, since rescue/else/ensure are allowed inside do/end blocks in Ruby 2.5 (https://bugs.ruby-lang.org/issues/12906), so we'd probably meets with that situation than before.
* Use native `Array#append`, `Array#prepend`, `Hash#transform_keys`, and ↵Ryuta Kamizono2018-12-201-1/+0
| | | | | | | | | | `Hash#transform_keys!` Since Rails 6 requires Ruby 2.5. https://github.com/ruby/ruby/blob/ruby_2_5/NEWS Follow up #34754.
* Require Ruby 2.5 for Rails 6.Kasper Timm Hansen2018-12-192-3/+3
| | | | | | | | | | Generally followed the pattern for https://github.com/rails/rails/pull/32034 * Removes needless CI configs for 2.4 * Targets 2.5 in rubocop * Updates existing CHANGELOG entries for fewer merge conflicts * Removes Hash#slice extension as that's inlined on Ruby 2.5. * Removes the need for send on define_method in MethodCallAssertions.
* Do not require `webpacker` in Active Job integration testsyuuji.yaginuma2018-12-081-0/+1
| | | | | | Because `skip-javascript` option is specified for the dummy application used in the integration tests. https://github.com/rails/rails/blob/bdc96802a7a4a8c6d183272e997430e8b9006498/activejob/test/support/integration/helper.rb#L14
* Improve deprecation message for enqueue returning falseRafael Mendonça França2018-12-052-1/+16
| | | | | | And make sure new applications in Rails 6.0 has this config enabled. Also, improve test coverage and add a CHANGELOG entry.
* Merge pull request #33992 from kirs/enqueue-return-falseRafael França2018-12-054-1/+53
|\ | | | | Make AJ::Base#enqueue return false if the job wasn't enqueued
| * Make AJ::Base#enqueue return false if the job wasn't enqueuedKir Shatrov2018-10-284-1/+53
| |
* | Do not deserialize GlobalID objects that were not generated by Active JobRafael Mendonça França2018-11-272-1/+5
| | | | | | | | | | | | | | Trusting any GlobaID object when deserializing jobs can allow attackers to access information that should not be accessible to them. Fix CVE-2018-16476.
* | Merge pull request #34376 from composerinteralia/default_queue_nameRafael França2018-11-232-2/+29
|\ \ | | | | | | Allow using queue prefix with a default queue name
| * | Allow using queue prefix with a default queue nameDaniel Colson2018-11-032-2/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #34366 Currently setting queue_name_prefix will not combine a prefix with the default_queue_name; it will only affect queue names set with `queue_as`. With this PR the prefix will affect the default_queue_name as well. Closes #19831 Currently setting default_queue_name doesn't actually affect the queue_name default (although default_queue_name does get used if you pass a falsey `part_name` to `queue_as`). This PR would get default_queue_name working as expected as well. Because the queue_name default is now a lambda wrapping the default_queue_name, rather than the default_queue_name itself, I had to update one test to use the instance method `#queue_name` (which `instance_exec`s the value) instead of the class method. I think this change is OK, since only the instance method is documented. There was a question about whether we want a `default_queue_name` configuration. If we want to get rid of it, I would also be happy to open a PR for that instead. It has been around for a while now, but it also hasn't really worked for a while now. r? @matthewd since you had an opinion about this before
* | | Keep executions for each specific exception (#34352)Alberto Almagro2018-11-235-4/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Keep executions for each specific declaration Fixes #34337 ActiveJob used the global executions counter to control the number of times a job should be retried. The problem with this approach was that in case a job raised different exceptions during its executions they weren't retried the number of times defined by their `attemps` number. **Example:** Having the following job: ```ruby class BuggyJob < ActiveJob::Base retry_on CustomException, attemps: 3 retry_on OtherException, attempts: 3 end ``` If the job raised `CustomException` in the first two executions and then it raised `OtherException`, the job wasn't retried anymore because the global executions counter was already indicating 3 attempts. With this patch each `retry_on` declaration has its specific counter so that the first two executions that raise `CustomException` don't affect the retries count that future exceptions may have. * Revert "clarifies documentation around the attempts arugment to retry_on" This reverts commit 86aa8f8c5631f77ed9a208e5107003c01512133e.
* | | Allow all ActiveJob assertion helper to accept Proc in their `only` kw:Edouard CHIN2018-11-214-4/+101
| | | | | | | | | | | | | | | | | | | | | | | | - That feature is useful to enqueue or assert that jobs got enqueued or performed based on dynamic conditions. We will be able to leverage that feature to fix all ActionMailer assertion helper issue when a Mailer define a custom delivery job (see next commit).
* | | Permit ActionController::Parameters for serializable HashBernie Chiu2018-11-193-3/+34
| | |
* | | Change queueing to queuing in docs and comments [skip ci]jacobherrington2018-11-187-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | My spellchecker flagged this as an incorrect spelling, upon further research it appears to be a point of contention in English. Either way might work. After further examination queuing is much more common in the Rails codebase so making this change will serve to standardize the spelling.
* | | Make `PERMITTED_TYPES` privateAlberto Almagro2018-11-121-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Document missing supported types [ci skip]Alberto Almagro2018-11-112-7/+12
| | | | | | | | | | | | | | | This commit adds missing types to the supported types list, which was extended in #30941
* | | Restore `private_constant` which is lost accidentally in #30941Ryuta Kamizono2018-11-091-1/+1
| | | | | | | | | | | | https://github.com/rails/rails/pull/30941/files#diff-fc90ec41ef75be8b2259526fe1a8b663L53
* | | Amend CVE note and security guide section wordingsGannon McGibbon2018-11-061-3/+3
| | | | | | | | | | | | | | | | | | | | | Reword first sentence of dep management and CVE section of security guide. Also, reword and move gemspec notes above deps. [ci skip]
* | | Add CVE note to security guide and gemspecsGannon McGibbon2018-11-061-0/+3
|/ / | | | | | | [ci skip]
* | Restore HWIA support to AJ::Arguments.deserializeGannon McGibbon2018-10-303-1/+13
| | | | | | | | | | Restore HashWithIndifferentAccess support to ActiveJob::Arguments.deserialize.
* | Merge pull request #33972 from bogdanvlviv/follow-up-33897Rafael França2018-10-302-9/+13
|\ \ | |/ |/| Improve `enqueue_retry.active_job` message
| * Improve `enqueue_retry.active_job` messagebogdanvlviv2018-09-252-9/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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?
* | Merge pull request #34204 from XrXr/aj-test-helper-argsRafael França2018-10-243-15/+20
|\ \ | | | | | | Include deserialized arguments in jobs returned by AJ test helpers
| * | Include deserialized arguments in jobs returned by AJ test helpersAlan Wu2018-10-123-15/+20
| | | | | | | | | | | | | | | | | | | | | | | | `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.
* | | Remove an extra `@mutex.synchronize`yuuji.yaginuma2018-10-191-12/+1
| | | | | | | | | | | | | | | | | | | | | | | | Since `@mutex.synchronize` is enforced in the `ensure_connection!` method, there is no need to do so on the caller side. https://github.com/jondot/sneakers/blob/c1b47f9c5d5a95da728bbe1700795790e4efbb12/lib/sneakers/publisher.rb#L22-L26 Due to this, `ThreadError(deadlock; recursive locking)` has occurred.
* | | Return a non zero code when can not connect to backend on CIyuuji.yaginuma2018-10-194-4/+8
| | |
* | | Clarify docs of `ActiveJob::TestHelper` [ci skip]bogdanvlviv2018-10-161-3/+3
| | | | | | | | | | | | | | | | | | | | | I found a few sentences that should be updated as well. See https://github.com/rails/rails/pull/33571#discussion_r209435886 Follow up #33571
* | | [ci skip] Fix link to Concurrent::ThreadPoolExecutor docsOrhan Toy2018-10-111-1/+1
| | |
* | | Remove unnecessary use of `included` in ActiveJob::CoreAlan Wu2018-10-051-21/+19
|/ / | | | | | | | | Using `included` to define `attr_acessor` and `attr_writer` is causing these methods to not show up in the documentation.
* | Add `Style/RedundantFreeze` to remove redudant `.freeze`Yasuo Honda2018-09-292-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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] (#33571)Mohit Natoo2018-09-281-8/+8
| | | | | | | | | | | | | | * Documentation clarity in ActiveJob::TestHelper [ci skip] * Documentation for options [Mohit Natoo + Rafael Mendonça França]
* | Merge pull request #33570 from mohitnatoo/queue_adapter_name_docRyuta Kamizono2018-09-281-0/+2
|\ \ | | | | | | | | | | | | Documentation for queue_adapter_name method in ActiveJob::QueueAdapter [ci skip]
| * | Documentation for queue_adapter_name method in ActiveJob::QueueAdapter [ci skip]Mohit Natoo2018-08-101-0/+2
| | |
* | | Add a way to check for subset of arguments when performing jobs:Edouard CHIN2018-09-263-2/+100
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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.
* | | Change the empty block style to have space inside of the blockRafael Mendonça França2018-09-251-1/+1
| |/ |/|
* | Extract `instrument` method.Kasper Timm Hansen2018-09-231-26/+11
| | | | | | | | Similar to Action View's and Action Controller's instrument helpers.
* | Fix "warning: shadowing outer local variable - job"yuuji.yaginuma2018-09-221-2/+2
| |
* | Merge pull request #33906 from dark-panda/ignore-psqlrc-when-using-psqlRafael França2018-09-202-4/+4
|\ \ | | | | | | Ignore psqlrc files when executing psql commands
| * | Ignore psqlrc files when executing psql commandsJ Smith2018-09-172-4/+4
| | | | | | | | | | | | | | | | | | psqlrc files can affect the execution of commands in ways that can hold up execution by blocking or otherwise cause unexpected side effects and should best be ignored when using psql programmatically.
* | | Make `assert_<enqueued|performed>_with()` compare hashes ignoring order of keysSharang Dashputre2018-09-213-9/+38
| | | | | | | | | | | | The test helpers now treat `{ a: 1, b: 2 }` and `{ b: 2, a: 1 }` as equals
* | | Merge pull request #33897 from bogdanvlviv/follow-up-33751Rafael França2018-09-183-12/+23
|\ \ \ | |/ / |/| | Follow up #33751
| * | `retry_job` should publish `enqueue_retry.active_job` notificationbogdanvlviv2018-09-163-12/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Print correct rake command on running AJ integration testsbogdanvlviv2018-09-171-1/+1
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently when executing `bundle exec rake test:integration` under `activejob/` derectory, it prints helpful info like: ``` (snip) *** rake aj:integration:async *** (snip) *** rake aj:integration:delayed_job *** (snip) ``` but there is no defined `:aj` scope in `activejob/Rakefile`, so I think output should be like: ``` (snip) *** rake test:integration:async *** (snip) *** rake test:integration:delayed_job *** (snip) ``` By the way `rake test:integration` doesn't work if execute it without prepending `bundle exec` to that command. It is probably what we should fix too.
* | Update arguments.rb [ci skip]Sharang Dashputre2018-09-131-1/+1
| | | | | | | | Fix typo `Instrinsic` -> `Intrinsic`
* | Add changelog entries for #33849 [ci skip]bogdanvlviv2018-09-131-0/+4
| | | | | | | | | | | | | | Since these changes related to the public API, I think we should add changelog entries. Related to #33838, #33849
* | Merge pull request #33849 from ↵Rafael França2018-09-121-0/+4
|\ \ | | | | | | | | | | | | ricardotk002/include-helpers-action-dispatch-integration-test Include test helpers in ActionDispatch::IntegrationTest
| * | Include test helpers when ActionDispatch::IntegrationTest is loadedRicardo Díaz2018-09-121-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Update test_helper_test.rbSharang Dashputre2018-09-121-1/+1
|/ / | | | | Fix typo `wiht` -> `with`