Commit Graph

781 Commits

Author SHA1 Message Date
Rafael Mendonça França 83d85b2207
Start Rails 7.1 development 2021-12-07 15:52:30 +00:00
Rafael Mendonça França 7c788e9175
Remove deprecated `:return_false_on_aborted_enqueue` option 2021-11-19 23:15:58 +00:00
Rafael Mendonça França 10bd5e59c3
Removed deprecated behavior that was not halting `after_enqueue`/`after_perform` callbacks when a previous callback was halted with `throw :abort`. 2021-11-17 21:51:17 +00:00
Rafael Mendonça França 1fde031e89 Fix gemspec 2021-11-15 21:06:21 +00:00
Rafael Mendonça França 9195b7fd0a
Require MFA to release rails 2021-11-15 20:37:42 +00:00
shunyama 4e2d55e1aa fix tiny grammatical mistakes[skip ci] 2021-11-13 00:58:14 +09:00
Jean Boussier 6bad959565 Extract ActiveSupport::ExecutionContext out of ActiveRecord::QueryLogs
I'm working on a standardized error reporting interface
(https://github.com/rails/rails/issues/43472) and it has the same need
for a `context` than Active Record's query logs.

Just like query logs, when reporting an error you want to know what the
current controller or job is, etc.

So by extracting it we can allow both API to use the same store.
2021-11-10 09:36:02 +01:00
Dorian Marié 13b3c46365 fix typo of using where instead of were 2021-11-07 14:17:00 +01:00
HParker 29e502f374 Improve active_job test_helper error messages
Error messages from assert_enqueued_with and assert_performed_with
shows which other jobs are enqueued or performed when you get an
error.  We can improve these messages to make it clearer why the job
didn't match. This one error messages now have three different formats
based on why the job didn't match

1. Didn't match because no jobs are queued at all. This now reports,
```
No performed job found with {:job=>HelloJob, :args=>[]}

No jobs where performed
```

2. Didn't match because that job class was not queued. This now reports,
```
No performed job found with {:job=>MultipleKwargsJob, :args=>[#<Person:0x00007fe38f9f8100 @id=11>]}

No jobs of class MultipleKwargsJob where performed, job classes performed: HelloJob
```

3. Doesn't match due to arguments, queue, priority or other reason. This now reports
```
No performed job found with {:job=>HelloJob, :args=>[#<Person:0x00007fe3a89fc2c8 @id=11>]}

Potential matches: {"job_class"=>"HelloJob", "job_id"=>"f8636fd9-c7a0-4565-9198-17e175f30f0e", "provider_job_id"=>nil, "queue_name"=>"default", "priority"=>nil, "arguments"=>[{"_aj_globalid"=>"gid://aj/Person/9"}], "executions"=>0, "exception_executions"=>{}, "locale"=>"en", "timezone"=>nil, "enqueued_at"=>"2021-10-27T23:19:54Z", :job=>HelloJob, :args=>[#<Person:0x00007fe3a89dce00 @id="9">], :queue=>"default", :priority=>nil}
```

Which matches the old error message, but only reports jobs that where
queued of the same class as the job you are asserting was queued.
2021-10-27 16:31:50 -07:00
Jean Boussier 51c45d334c Refactor ActiveRecord::QueryLogs context API
This remove the null object as discussed in
8af78700d2.
Since it pretends to be nil but acts as thruthy in boolean context
it cause more confusion than it clean code.

`update_context` is removed in favor of `set_context` without
a block.
2021-10-26 09:55:33 +02:00
Veerpal Brar 0f259e702d Raise error when serializing an anonymous class.
The ModuleSerializer does not support serializing anonymous classes
because when we try to deserialize the anonymous class, it wouldn't
know which class to use (since class name is nil).

For this reason, ModuleSerialzier now raises an error if the class
name is nil. Previously, ModuleSerializer would raise an `undefined
method `constantize' for nil:NilClass` error during deserialization.
It's not clear why the deserialization failed from the error.

In this commit, we raise an explicit error when trying to serialize
an anonymous class indicating this behaviour is not supported.
2021-10-13 11:55:23 -04:00
Ben Sheldon c4fcb4e6ee Allow `ActiveJob::Base.set` to configure job when using `.perform_now` 2021-10-12 13:53:38 -07:00
Rafael Mendonça França d177551c30
Preparing for 7.0.0.alpha2 release 2021-09-15 18:22:51 -04:00
Rafael Mendonça França 9b7be48212
Preparing for 7.0.0.alpha1 release 2021-09-15 17:55:08 -04:00
David Heinemeier Hansson 7595c922a6
Use the combined jsbundling-rails gem instead of individual js bundler gems (#43172)
* Use the combined jsbundling-rails gem instead of individual js bundler gems

* Remove Webpacker remnants

* Replace webpacker with jsbundling-rails
2021-09-06 16:44:44 +02:00
Jean Boussier c91c266872 Enable `Style/ExplicitBlockArgument` cop
This reduce the stack size which is beneficial for
exceptions performance.

See: https://gist.github.com/byroot/cb3bcadcc3701c2518d002fb8d3a4e7a

However the cop is unsafe because it might change the block arity,
so it can run into some false positives.
2021-09-05 17:06:19 +02:00
Jean Boussier af87199a80 Handle NullObject instances in Active Job query tag 2021-08-24 15:07:20 +02:00
Jean Boussier b9635ccc05 Pass `ActiveRecord::QueryLogs` as argument rather than `instance_exec`
Otherwise we expose all the interal state of `QueryLogs` as an API.

It also makes the API more friendly to typing frameworks.
2021-08-23 20:29:45 +02:00
Xavier Noria 324883dc50 Delete extra empty line 2021-08-22 01:28:14 +02:00
Xavier Noria 7c09e59bca Restore AJ autoloading test
This commit restores the test deleted in

    cd22ecbfc2

Active Job should not test things about autoloading, this would
belong to the railties test suite probably. However, there, it feels
a bit too distant from here.

Imperfect, but on a second thought I believe this trade-off is better.
2021-08-22 01:23:14 +02:00
Rafael Mendonça França 614fc3d827
Delay the exclusion of the configs to the last minute
The framework still rely on the configuration object being modified
in initializers, so we need to delay the exclusion to the last minute.
2021-08-18 00:04:25 +00:00
Rafael Mendonça França ac77ab469f
Only try to configure the query log tags if Active Record is present 2021-08-17 23:35:47 +00:00
Rafael Mendonça França a6aa9376f1
Stop relying on mutating the configuration object 2021-08-17 23:35:46 +00:00
Rafael Mendonça França 8af78700d2
Improve taggings API by introducing a null object
Instead of adding chains of `&.` we should use a null object to allow
the taggings definition to be more concise.
2021-08-17 23:35:44 +00:00
Rafael Mendonça França 18cd634e07
Fix initialization proccess of the query tags
The tags were being added in the wrong way, now it is always using the
configuration.
2021-08-17 22:59:44 +00:00
Rafael Mendonça França 6d983e86da
Remove more unneeded methods that should be configs 2021-08-17 22:35:22 +00:00
Rafael Mendonça França 3597afc605
Avoid using class_eval and just include a module 2021-08-17 22:16:06 +00:00
Rafael Mendonça França e214f25463
Do not change the framework if all we want are configs
The value of the configs in the base classes were not being used in
the code. We only needed configs, so we can just use that.
2021-08-17 22:13:00 +00:00
Koichi ITO 65af100ddd Tweak unreachable assertion tests in the block of `assert_raises`
I found an unexpected use of assertion in the block of `assert_raise`
when I implemented https://github.com/rubocop/rubocop-minitest/pull/137.
It is expected to be asserted after an exception is raised in
`assert_raise` block, but in actually it is not asserted after an
exception is raised. Therefore, this PR removes or updates assertions
that have not been asserted after an exception has raised.

This PR will add `rubocop-minitest` and enable
`Minitest/UnreachableAssertion` cop to able similar auto-detection,
but will remove `rubocop-minitest` from this PR if you don't like it.
2021-08-17 20:33:08 +09:00
David Heinemeier Hansson 21c9732fae
Remove spring as a default installation option (#42997)
* Remove spring as a default installation option

Faster computers have meant that most apps won't see a big benefit from Spring on small to moderate size apps. Thus the pain of dealing with the occasional spring issue is no longer warranted by default.

* Errant end

* No longer an option

* Additional spring removals

* Pointer to docs is enough
2021-08-12 12:31:18 +02:00
Keeran Raj Hawoldar 2408615154 Add QueryLogTags to Rails
Co-authored-by: Eileen M. Uchitelle <eileencodes@users.noreply.github.com>
Co-authored-by: Kasper Timm Hansen <kaspth@gmail.com>
2021-08-09 15:21:08 +01:00
Xavier Noria cd22ecbfc2 Deletes an AJ test that used classic
AJ infers adapater class names, and loads them. How are those classes made
available to AJ is a user's concern.

Perhaps they loaded the adapter with require, perhaps they have the class in the
autoload_once_paths. It does not matter, it is the user responsibility to make
the class available _somehow_, and AJ can assume that.
2021-08-09 13:39:51 +02:00
Alex Blair de28930d46 Avoid logging delayed job arguments if log_arguments set to false 2021-08-01 21:46:44 +01:00
Rafael Mendonça França 18707ab17f
Standardize nodoc comments 2021-07-29 21:18:07 +00:00
Daniel Morton 94ccd5410d
`retry_on` parameter `attempts` now accepts `:unlimited` (#41761)
In some applications, some classes of errors may be raised during the
execution of a job which the developer would want to retry forever.

These classes of errors would most likely be infrastructure problems that
the developer knows will be resolved eventually but may take a variable
amount of time or errors where due to application business logic, there
could be something temporarily blocking the job from executing, like a
resource that is needed for the job being locked for a lengthy amount of
time.

While an arbitrarily large number of attempts could previously be passed,
this is inexpressive as sometimes the developer may just need the job to
continue to be retried until it eventually succeeds. Without this,
developers would need to include additional code to handle the situation
where the job eventually fails its attempts limit and has to be re-enqueued
manually.

As with many things this should be used with caution and only for errors
that the developer knows will definitely eventually be resolved, allowing
the job to continue.

[Daniel Morton + Rafael Mendonça França]
2021-07-28 18:32:19 -04:00
akhilgkrishnan bf79a4c8e2 Active job basic doc grammer mistakes fixed 2021-07-26 22:41:20 +05:30
Ryuta Kamizono e50b0e3ab3 Fixup CHANGELOGs [ci skip] 2021-07-21 10:08:08 +09:00
Wojciech Wnętrzak e2db5f205a
Added possibility to check on `:priority` in test helper methods 2021-07-15 07:46:21 +02:00
Alex Ghiculescu 4b42beb3b8 Log a warning when assertions are incorrectly nested and errors are raised
Follow up to https://github.com/rails/rails/pull/37313

- Adds regression tests
- Logs a warning in cases where assertions are nested in a way that's likely to be confusing
2021-07-12 10:37:43 -05:00
Dirkjan Bussink 0523532a3c
Always use OpenSSL constants for Digest operations
As also previously discussed in
https://github.com/rails/rails/pull/40770#issuecomment-748347066, this
moves the usage of Digest constants to always use the OpenSSL version of
those Digest implementations.
2021-06-30 13:57:54 +02:00
Ashik Salman 6a6c6ca207 Added more regression for activejob Range serializer. 2021-05-18 16:29:34 +05:30
Andrew White 61fb58f6a7
Add Range to list of supported arguments for jobs 2021-05-16 08:44:59 +01:00
Felipe Sateler 5bb5453cd7 Add Range serializer for ActiveJob
Missing Range support means users need to add start/finish pair
of arguments instead of simply passing a Range object.
2021-05-15 23:22:26 -04:00
John Bampton de3b207aa6 chore: fix grammar and spelling 2021-04-15 16:57:01 +10:00
Rafael Mendonça França 4354e3ae49
Don't define methods using the method modifier in the same line as the method
Our style guide use block method modifiers, not inline method modifiers.
2021-04-12 18:49:54 +00:00
Jean Boussier 3f59640016 Stop checking if ruby2_keywords is defined 2021-04-11 13:42:02 +02:00
Jean Boussier 8a3fcad2d2 Use ... argument forwarding instead of ruby2_keywords when possible 2021-03-19 16:53:06 +01:00
Jonathan Hefner 167f5c8065 Fix inline code markup [ci-skip]
RDoc Markup does not support backticks the way Markdown does to mark up
inline code.  Additionally, `<tt>` must be used to mark up inline code
that includes spaces or certain punctuation characters (e.g. quotes).
2021-02-14 11:20:35 -06:00
Ryuta Kamizono 39e49edaf9 Remove the code for older Rubies `RUBY_VERSION < "2.7"` in the codebase 2021-02-07 12:20:18 +09:00
Ryuta Kamizono f8b354bf3b Fix typo s/adapaters/adapters/ [ci skip] 2021-02-07 05:41:07 +09:00